merge from donut
diff --git a/api/current.xml b/api/current.xml
index fc54859..76ee852 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -158866,7 +158866,7 @@
  synchronized="true"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -159300,7 +159300,7 @@
  synchronized="true"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="use" type="boolean">
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 9834c75..a67e60b 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -458,7 +458,9 @@
                 sb.append(this.vibrate[i]);
                 sb.append(',');
             }
-            sb.append(this.vibrate[N]);
+            if (N != -1) {
+                sb.append(this.vibrate[N]);
+            }
             sb.append("]");
         } else if ((this.defaults & DEFAULT_VIBRATE) != 0) {
             sb.append("default");
diff --git a/core/java/android/bluetooth/BluetoothInputStream.java b/core/java/android/bluetooth/BluetoothInputStream.java
new file mode 100644
index 0000000..ceae70c
--- /dev/null
+++ b/core/java/android/bluetooth/BluetoothInputStream.java
@@ -0,0 +1,62 @@
+/*
+ * 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.bluetooth;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * BluetoothInputStream.
+ *
+ * Used to write to a Bluetooth socket.
+ *
+ * TODO: Implement bulk writes (instead of one byte at a time).
+ * @hide
+ */
+/*package*/ final class BluetoothInputStream extends InputStream {
+    private BluetoothSocket mSocket;
+
+    /*package*/ BluetoothInputStream(BluetoothSocket s) {
+        mSocket = s;
+    }
+
+    /**
+     * Return number of bytes available before this stream will block.
+     */
+    public int available() throws IOException {
+        return mSocket.availableNative();
+    }
+
+    public void close() throws IOException {
+        mSocket.close();
+    }
+
+    /**
+     * Reads a single byte from this stream and returns it as an integer in the
+     * range from 0 to 255. Returns -1 if the end of the stream has been
+     * reached. Blocks until one byte has been read, the end of the source
+     * stream is detected or an exception is thrown.
+     *
+     * @return the byte read or -1 if the end of stream has been reached.
+     * @throws IOException
+     *             if the stream is closed or another IOException occurs.
+     * @since Android 1.0
+     */
+    public int read() throws IOException {
+        return mSocket.readNative();
+    }
+}
diff --git a/core/java/android/bluetooth/BluetoothOutputStream.java b/core/java/android/bluetooth/BluetoothOutputStream.java
new file mode 100644
index 0000000..32e6d17
--- /dev/null
+++ b/core/java/android/bluetooth/BluetoothOutputStream.java
@@ -0,0 +1,57 @@
+/*
+ * 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.bluetooth;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * BluetoothOutputStream.
+ *
+ * Used to read from a Bluetooth socket.
+ *
+ * TODO: Implement bulk reads (instead of one byte at a time).
+ * @hide
+ */
+/*package*/ final class BluetoothOutputStream extends OutputStream {
+    private BluetoothSocket mSocket;
+
+    /*package*/ BluetoothOutputStream(BluetoothSocket s) {
+        mSocket = s;
+    }
+
+    /**
+     * Close this output stream and the socket associated with it.
+     */
+    public void close() throws IOException {
+        mSocket.close();
+    }
+
+    /**
+     * Writes a single byte to this stream. Only the least significant byte of
+     * the integer {@code oneByte} is written to the stream.
+     *
+     * @param oneByte
+     *            the byte to be written.
+     * @throws IOException
+     *             if an error occurs while writing to this stream.
+     * @since Android 1.0
+     */
+    public void write(int oneByte) throws IOException {
+        mSocket.writeNative(oneByte);
+    }
+}
diff --git a/core/java/android/bluetooth/BluetoothServerSocket.java b/core/java/android/bluetooth/BluetoothServerSocket.java
new file mode 100644
index 0000000..ca46701
--- /dev/null
+++ b/core/java/android/bluetooth/BluetoothServerSocket.java
@@ -0,0 +1,124 @@
+/*
+ * 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.bluetooth;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * Server (listening) Bluetooth Socket.
+ *
+ * Currently only supports RFCOMM sockets.
+ *
+ * RFCOMM is a connection orientated, streaming transport over Bluetooth. It is
+ * also known as the Serial Port Profile (SPP).
+ *
+ * TODO: Consider implementing SCO and L2CAP sockets.
+ * TODO: Clean up javadoc grammer and formatting.
+ * TODO: Remove @hide
+ * @hide
+ */
+public final class BluetoothServerSocket implements Closeable {
+    private final BluetoothSocket mSocket;
+
+    /**
+     * Construct a listening, secure RFCOMM server socket.
+     * The remote device connecting to this socket will be authenticated and
+     * communication on this socket will be encrypted.
+     * Call #accept to retrieve connections to this socket.
+     * @return An RFCOMM BluetoothServerSocket
+     * @throws IOException On error, for example Bluetooth not available, or
+     *                     insufficient permissions.
+     */
+    public static BluetoothServerSocket listenUsingRfcommOn(int port) throws IOException {
+        BluetoothServerSocket socket = new BluetoothServerSocket(true, true);
+        try {
+            socket.mSocket.bindListenNative(port);
+        } catch (IOException e) {
+            try {
+                socket.close();
+            } catch (IOException e2) { }
+            throw e;
+        }
+        return socket;
+    }
+
+    /**
+     * Construct an unencrypted, unauthenticated, RFCOMM server socket.
+     * Call #accept to retrieve connections to this socket.
+     * @return An RFCOMM BluetoothServerSocket
+     * @throws IOException On error, for example Bluetooth not available, or
+     *                     insufficient permissions.
+     */
+    public static BluetoothServerSocket listenUsingInsecureRfcommOn(int port) throws IOException {
+        BluetoothServerSocket socket = new BluetoothServerSocket(false, false);
+        try {
+            socket.mSocket.bindListenNative(port);
+        } catch (IOException e) {
+            try {
+                socket.close();
+            } catch (IOException e2) { }
+            throw e;
+        }
+        return socket;
+    }
+
+    /**
+     * Construct a socket for incoming connections.
+     * @param auth    Require the remote device to be authenticated
+     * @param encrypt Require the connection to be encrypted
+     * @throws IOException On error, for example Bluetooth not available, or
+     *                     insufficient priveleges
+     */
+    private BluetoothServerSocket(boolean auth, boolean encrypt) throws IOException {
+        mSocket = new BluetoothSocket(-1, auth, encrypt, null, -1);
+    }
+
+    /**
+     * Block until a connection is established.
+     * Returns a connected #BluetoothSocket. This server socket can be reused
+     * for subsequent incoming connections by calling #accept repeatedly.
+     * #close can be used to abort this call from another thread.
+     * @return A connected #BluetoothSocket
+     * @throws IOException On error, for example this call was aborted
+     */
+    public BluetoothSocket accept() throws IOException {
+        return accept(-1);
+    }
+
+    /**
+     * Block until a connection is established, with timeout.
+     * Returns a connected #BluetoothSocket. This server socket can be reused
+     * for subsequent incoming connections by calling #accept repeatedly.
+     * #close can be used to abort this call from another thread.
+     * @return A connected #BluetoothSocket
+     * @throws IOException On error, for example this call was aborted, or
+     *                     timeout
+     */
+    public BluetoothSocket accept(int timeout) throws IOException {
+        return mSocket.acceptNative(timeout);
+    }
+
+    /**
+     * Closes this socket.
+     * This will cause other blocking calls on this socket to immediately
+     * throw an IOException.
+     */
+    public void close() throws IOException {
+        mSocket.closeNative();
+    }
+}
diff --git a/core/java/android/bluetooth/BluetoothSocket.java b/core/java/android/bluetooth/BluetoothSocket.java
new file mode 100644
index 0000000..fd8885e
--- /dev/null
+++ b/core/java/android/bluetooth/BluetoothSocket.java
@@ -0,0 +1,176 @@
+/*
+ * 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.bluetooth;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Represents a connected or connecting Bluetooth Socket.
+ *
+ * Currently only supports RFCOMM sockets.
+ *
+ * RFCOMM is a connection orientated, streaming transport over Bluetooth. It is
+ * also known as the Serial Port Profile (SPP).
+ *
+ * TODO: Consider implementing SCO and L2CAP sockets.
+ * TODO: Clean up javadoc grammer and formatting.
+ * TODO: Remove @hide
+ * @hide
+ */
+public final class BluetoothSocket implements Closeable {
+    private final int mPort;
+    private final String mAddress;    /* remote address */
+    private final boolean mAuth;
+    private final boolean mEncrypt;
+    private final BluetoothInputStream mInputStream;
+    private final BluetoothOutputStream mOutputStream;
+
+    private int mSocketData;    /* used by native code only */
+
+    /**
+     * Construct a secure RFCOMM socket ready to start an outgoing connection.
+     * Call #connect on the returned #BluetoothSocket to begin the connection.
+     * The remote device will be authenticated and communication on this socket
+     * will be encrypted.
+     * @param address remote Bluetooth address that this socket can connect to
+     * @param port    remote port
+     * @return an RFCOMM BluetoothSocket
+     * @throws IOException on error, for example Bluetooth not available, or
+     *                     insufficient permissions.
+     */
+    public static BluetoothSocket createRfcommSocket(String address, int port)
+            throws IOException {
+        return new BluetoothSocket(-1, true, true, address, port);
+    }
+
+    /**
+     * Construct an insecure RFCOMM socket ready to start an outgoing
+     * connection.
+     * Call #connect on the returned #BluetoothSocket to begin the connection.
+     * The remote device will not be authenticated and communication on this
+     * socket will not be encrypted.
+     * @param address remote Bluetooth address that this socket can connect to
+     * @param port    remote port
+     * @return An RFCOMM BluetoothSocket
+     * @throws IOException On error, for example Bluetooth not available, or
+     *                     insufficient permissions.
+     */
+    public static BluetoothSocket createInsecureRfcommSocket(String address, int port)
+            throws IOException {
+        return new BluetoothSocket(-1, false, false, address, port);
+    }
+
+    /**
+     * Construct a Bluetooth.
+     * @param fd      fd to use for connected socket, or -1 for a new socket
+     * @param auth    require the remote device to be authenticated
+     * @param encrypt require the connection to be encrypted
+     * @param address remote Bluetooth address that this socket can connect to
+     * @param port    remote port
+     * @throws IOException On error, for example Bluetooth not available, or
+     *                     insufficient priveleges
+     */
+    /*package*/ BluetoothSocket(int fd, boolean auth, boolean encrypt, String address, int port)
+            throws IOException {
+        mAuth = auth;
+        mEncrypt = encrypt;
+        mAddress = address;
+        mPort = port;
+        if (fd == -1) {
+            initSocketNative();
+        } else {
+            initSocketFromFdNative(fd);
+        }
+        mInputStream = new BluetoothInputStream(this);
+        mOutputStream = new BluetoothOutputStream(this);
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        try {
+            close();
+        } finally {
+            super.finalize();
+        }
+    }
+
+    /**
+     * Attempt to connect to a remote device.
+     * This method will block until a connection is made or the connection
+     * fails. If this method returns without an exception then this socket
+     * is now connected. #close can be used to abort this call from another
+     * thread.
+     * @throws IOException On error, for example connection failure
+     */
+    public void connect() throws IOException {
+        connectNative(mAddress, mPort, -1);
+    }
+
+    /**
+     * Closes this socket.
+     * This will cause other blocking calls on this socket to immediately
+     * throw an IOException.
+     */
+    public void close() throws IOException {
+        closeNative();
+    }
+
+    /**
+     * Return the address we are connecting, or connected, to.
+     * @return Bluetooth address, or null if this socket has not yet attempted
+     *         or established a connection.
+     */
+    public String getAddress() {
+        return mAddress;
+    }
+
+    /**
+     * Get the input stream associated with this socket.
+     * The input stream will be returned even if the socket is not yet
+     * connected, but operations on that stream will throw IOException until
+     * the associated socket is connected.
+     * @return InputStream
+     */
+    public InputStream getInputStream() throws IOException {
+        return mInputStream;
+    }
+
+    /**
+     * Get the output stream associated with this socket.
+     * The output stream will be returned even if the socket is not yet
+     * connected, but operations on that stream will throw IOException until
+     * the associated socket is connected.
+     * @return OutputStream
+     */
+    public OutputStream getOutputStream() throws IOException {
+        return mOutputStream;
+    }
+
+    private native void initSocketNative();
+    private native void initSocketFromFdNative(int fd);
+    private native void connectNative(String address, int port, int timeout);
+    /*package*/ native void bindListenNative(int port) throws IOException;
+    /*package*/ native BluetoothSocket acceptNative(int timeout) throws IOException;
+    /*package*/ native int availableNative();
+    /*package*/ native int readNative();
+    /*package*/ native void writeNative(int data);
+    /*package*/ native void closeNative();
+    private native void destroyNative();
+}
diff --git a/core/java/android/bluetooth/Database.java b/core/java/android/bluetooth/Database.java
deleted file mode 100644
index fef641a..0000000
--- a/core/java/android/bluetooth/Database.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2007 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.bluetooth;
-
-import android.bluetooth.RfcommSocket;
-
-import android.util.Log;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * The Android Bluetooth API is not finalized, and *will* change. Use at your
- * own risk.
- * 
- * A low-level API to the Service Discovery Protocol (SDP) Database.
- *
- * Allows service records to be added to the local SDP database. Once added,
- * these services will be advertised to remote devices when they make SDP
- * queries on this device.
- *
- * Currently this API is a thin wrapper to the bluez SDP Database API. See:
- * http://wiki.bluez.org/wiki/Database
- * http://wiki.bluez.org/wiki/HOWTO/ManagingServiceRecords
- * @hide
- */
-public final class Database {
-    private static Database mInstance;
-
-    private static final String sLogName = "android.bluetooth.Database";
-
-    /**
-     * Class load time initialization
-     */
-    static {
-        classInitNative();
-    }
-    private native static void classInitNative();
-
-    /**
-     * Private to enforce singleton property
-     */
-    private Database() {
-        initializeNativeDataNative();
-    }
-    private native void initializeNativeDataNative();
-
-    protected void finalize() throws Throwable {
-        try {
-            cleanupNativeDataNative();
-        } finally {
-            super.finalize();
-        }
-    }
-    private native void cleanupNativeDataNative();
-
-    /**
-     * Singelton accessor
-     * @return The singleton instance of Database
-     */
-    public static synchronized Database getInstance() {
-        if (mInstance == null) {
-            mInstance = new Database();
-        }
-        return mInstance;
-    }
-
-    /**
-     * Advertise a service with an RfcommSocket.
-     *
-     * This adds the service the SDP Database with the following attributes
-     * set: Service Name, Protocol Descriptor List, Service Class ID List
-     * TODO: Construct a byte[] record directly, rather than via XML.
-     * @param       socket The rfcomm socket to advertise (by channel).
-     * @param       serviceName A short name for this service
-     * @param       uuid
-     *                  Unique identifier for this service, by which clients
-     *                  can search for your service
-     * @return      Handle to the new service record
-     */
-    public int advertiseRfcommService(RfcommSocket socket,
-                                      String serviceName,
-                                      UUID uuid) throws IOException {
-        String xmlRecord =
-                "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
-                "<record>\n" +
-                "  <attribute id=\"0x0001\">\n" + // ServiceClassIDList
-                "    <sequence>\n" +
-                "      <uuid value=\""
-                        + uuid.toString() +       // UUID for this service
-                        "\"/>\n" +
-                "    </sequence>\n" +
-                "  </attribute>\n" +
-                "  <attribute id=\"0x0004\">\n" + // ProtocolDescriptorList
-                "    <sequence>\n" +
-                "      <sequence>\n" +
-                "        <uuid value=\"0x0100\"/>\n" +  // L2CAP
-                "      </sequence>\n" +
-                "      <sequence>\n" +
-                "        <uuid value=\"0x0003\"/>\n" +  // RFCOMM
-                "        <uint8 value=\"" +
-                        socket.getPort() +              // RFCOMM port
-                        "\" name=\"channel\"/>\n" +
-                "      </sequence>\n" +
-                "    </sequence>\n" +
-                "  </attribute>\n" +
-                "  <attribute id=\"0x0100\">\n" + // ServiceName
-                "    <text value=\"" + serviceName + "\"/>\n" +
-                "  </attribute>\n" +
-                "</record>\n";
-        Log.i(sLogName, xmlRecord);
-        return addServiceRecordFromXml(xmlRecord);
-    }
-
-
-    /**
-     * Add a new service record.
-     * @param record The byte[] record
-     * @return       A handle to the new record
-     */
-    public synchronized int addServiceRecord(byte[] record) throws IOException {
-        int handle = addServiceRecordNative(record);
-        Log.i(sLogName, "Added SDP record: " + Integer.toHexString(handle));
-        return handle;
-    }
-    private native int addServiceRecordNative(byte[] record)
-            throws IOException;
-
-    /**
-     * Add a new service record, using XML.
-     * @param record The record as an XML string
-     * @return       A handle to the new record
-     */
-    public synchronized int addServiceRecordFromXml(String record) throws IOException {
-        int handle = addServiceRecordFromXmlNative(record);
-        Log.i(sLogName, "Added SDP record: " + Integer.toHexString(handle));
-        return handle;
-    }
-    private native int addServiceRecordFromXmlNative(String record)
-            throws IOException;
-
-    /**
-     * Update an exisiting service record.
-     * @param handle Handle to exisiting record
-     * @param record The updated byte[] record
-     */
-    public synchronized void updateServiceRecord(int handle, byte[] record) {
-        try {
-            updateServiceRecordNative(handle, record);
-        } catch (IOException e) {
-            Log.e(getClass().toString(), e.getMessage());
-        }
-    }
-    private native void updateServiceRecordNative(int handle, byte[] record)
-            throws IOException;
-
-    /**
-     * Update an exisiting record, using XML.
-     * @param handle Handle to exisiting record
-     * @param record The record as an XML string.
-     */
-    public synchronized void updateServiceRecordFromXml(int handle, String record) {
-        try {
-            updateServiceRecordFromXmlNative(handle, record);
-        } catch (IOException e) {
-            Log.e(getClass().toString(), e.getMessage());
-        }
-    }
-    private native void updateServiceRecordFromXmlNative(int handle, String record)
-            throws IOException;
-
-    /**
-     * Remove a service record.
-     * It is only possible to remove service records that were added by the
-     * current connection.
-     * @param handle Handle to exisiting record to be removed
-     */
-    public synchronized void removeServiceRecord(int handle) {
-        try {
-            removeServiceRecordNative(handle);
-        } catch (IOException e) {
-            Log.e(getClass().toString(), e.getMessage());
-        }
-    }
-    private native void removeServiceRecordNative(int handle) throws IOException;
-}
diff --git a/core/java/android/bluetooth/RfcommSocket.java b/core/java/android/bluetooth/RfcommSocket.java
deleted file mode 100644
index a33263f..0000000
--- a/core/java/android/bluetooth/RfcommSocket.java
+++ /dev/null
@@ -1,674 +0,0 @@
-/*
- * Copyright (C) 2007 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.bluetooth;
-
-import java.io.IOException;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.io.OutputStream;
-import java.io.InputStream;
-import java.io.FileDescriptor;
-
-/**
- * The Android Bluetooth API is not finalized, and *will* change. Use at your
- * own risk.
- * 
- * This class implements an API to the Bluetooth RFCOMM layer. An RFCOMM socket
- * is similar to a normal socket in that it takes an address and a port number.
- * The difference is of course that the address is a Bluetooth-device address,
- * and the port number is an RFCOMM channel. The API allows for the
- * establishment of listening sockets via methods
- * {@link #bind(String, int) bind}, {@link #listen(int) listen}, and
- * {@link #accept(RfcommSocket, int) accept}, as well as for the making of
- * outgoing connections with {@link #connect(String, int) connect},
- * {@link #connectAsync(String, int) connectAsync}, and
- * {@link #waitForAsyncConnect(int) waitForAsyncConnect}.
- * 
- * After constructing a socket, you need to {@link #create() create} it and then
- * {@link #destroy() destroy} it when you are done using it. Both
- * {@link #create() create} and {@link #accept(RfcommSocket, int) accept} return
- * a {@link java.io.FileDescriptor FileDescriptor} for the actual data.
- * Alternatively, you may call {@link #getInputStream() getInputStream} and
- * {@link #getOutputStream() getOutputStream} to retrieve the respective streams
- * without going through the FileDescriptor.
- *
- * @hide
- */
-public class RfcommSocket {
-
-    /**
-     * Used by the native implementation of the class.
-     */
-    private int mNativeData;
-
-    /**
-     * Used by the native implementation of the class.
-     */
-    private int mPort;
-
-    /**
-     * Used by the native implementation of the class.
-     */
-    private String mAddress;
-
-    /**
-     * We save the return value of {@link #create() create} and
-     * {@link #accept(RfcommSocket,int) accept} in this variable, and use it to
-     * retrieve the I/O streams.
-     */
-    private FileDescriptor mFd;
-
-    /**
-     * After a call to {@link #waitForAsyncConnect(int) waitForAsyncConnect},
-     * if the return value is zero, then, the the remaining time left to wait is
-     * written into this variable (by the native implementation). It is possible
-     * that {@link #waitForAsyncConnect(int) waitForAsyncConnect} returns before
-     * the user-specified timeout expires, which is why we save the remaining
-     * time in this member variable for the user to retrieve by calling method
-     * {@link #getRemainingAsyncConnectWaitingTimeMs() getRemainingAsyncConnectWaitingTimeMs}.
-     */
-    private int mTimeoutRemainingMs;
-
-    /**
-     * Set to true when an asynchronous (nonblocking) connect is in progress.
-     * {@see #connectAsync(String,int)}.
-     */
-    private boolean mIsConnecting;
-
-    /**
-     * Set to true after a successful call to {@link #bind(String,int) bind} and
-     * used for error checking in {@link #listen(int) listen}. Reset to false
-     * on {@link #destroy() destroy}.
-     */
-    private boolean mIsBound = false;
-
-    /**
-     * Set to true after a successful call to {@link #listen(int) listen} and
-     * used for error checking in {@link #accept(RfcommSocket,int) accept}.
-     * Reset to false on {@link #destroy() destroy}.
-     */
-    private boolean mIsListening = false;
-
-    /**
-     * Used to store the remaining time after an accept with a non-negative
-     * timeout returns unsuccessfully. It is possible that a blocking
-     * {@link #accept(int) accept} may wait for less than the time specified by
-     * the user, which is why we store the remainder in this member variable for
-     * it to be retrieved with method
-     * {@link #getRemainingAcceptWaitingTimeMs() getRemainingAcceptWaitingTimeMs}.
-     */
-    private int mAcceptTimeoutRemainingMs;
-
-    /**
-     * Maintained by {@link #getInputStream() getInputStream}.
-     */
-    protected FileInputStream mInputStream;
-
-    /**
-     * Maintained by {@link #getOutputStream() getOutputStream}.
-     */
-    protected FileOutputStream mOutputStream;
-
-    private native void initializeNativeDataNative();
-
-    /**
-     * Constructor.
-     */
-    public RfcommSocket() {
-        initializeNativeDataNative();
-    }
-
-    private native void cleanupNativeDataNative();
-
-    /**
-     * Called by the GC to clean up the native data that we set up when we
-     * construct the object.
-     */
-    protected void finalize() throws Throwable {
-        try {
-            cleanupNativeDataNative();
-        } finally {
-            super.finalize();
-        }
-    }
-
-    private native static void classInitNative();
-
-    static {
-        classInitNative();
-    }
-
-    /**
-     * Creates a socket. You need to call this method before performing any
-     * other operation on a socket.
-     * 
-     * @return FileDescriptor for the data stream.
-     * @throws IOException
-     * @see #destroy()
-     */
-    public FileDescriptor create() throws IOException {
-        if (mFd == null) {
-            mFd = createNative();
-        }
-        if (mFd == null) {
-            throw new IOException("socket not created");
-        }
-        return mFd;
-    }
-
-    private native FileDescriptor createNative();
-
-    /**
-     * Destroys a socket created by {@link #create() create}. Call this
-     * function when you no longer use the socket in order to release the
-     * underlying OS resources.
-     * 
-     * @see #create()
-     */
-    public void destroy() {
-        synchronized (this) {
-            destroyNative();
-            mFd = null;
-            mIsBound = false;
-            mIsListening = false;
-        }
-    }
-
-    private native void destroyNative();
-
-    /**
-     * Returns the {@link java.io.FileDescriptor FileDescriptor} of the socket.
-     * 
-     * @return the FileDescriptor
-     * @throws IOException
-     *             when the socket has not been {@link #create() created}.
-     */
-    public FileDescriptor getFileDescriptor() throws IOException {
-        if (mFd == null) {
-            throw new IOException("socket not created");
-        }
-        return mFd;
-    }
-
-    /**
-     * Retrieves the input stream from the socket. Alternatively, you can do
-     * that from the FileDescriptor returned by {@link #create() create} or
-     * {@link #accept(RfcommSocket, int) accept}.
-     * 
-     * @return InputStream
-     * @throws IOException
-     *             if you have not called {@link #create() create} on the
-     *             socket.
-     */
-    public InputStream getInputStream() throws IOException {
-        if (mFd == null) {
-            throw new IOException("socket not created");
-        }
-
-        synchronized (this) {
-            if (mInputStream == null) {
-                mInputStream = new FileInputStream(mFd);
-            }
-
-            return mInputStream;
-        }
-    }
-
-    /**
-     * Retrieves the output stream from the socket. Alternatively, you can do
-     * that from the FileDescriptor returned by {@link #create() create} or
-     * {@link #accept(RfcommSocket, int) accept}.
-     * 
-     * @return OutputStream
-     * @throws IOException
-     *             if you have not called {@link #create() create} on the
-     *             socket.
-     */
-    public OutputStream getOutputStream() throws IOException {
-        if (mFd == null) {
-            throw new IOException("socket not created");
-        }
-
-        synchronized (this) {
-            if (mOutputStream == null) {
-                mOutputStream = new FileOutputStream(mFd);
-            }
-
-            return mOutputStream;
-        }
-    }
-
-    /**
-     * Starts a blocking connect to a remote RFCOMM socket. It takes the address
-     * of a device and the RFCOMM channel (port) to which to connect.
-     * 
-     * @param address
-     *            is the Bluetooth address of the remote device.
-     * @param port
-     *            is the RFCOMM channel
-     * @return true on success, false on failure
-     * @throws IOException
-     *             if {@link #create() create} has not been called.
-     * @see #connectAsync(String, int)
-     */
-    public boolean connect(String address, int port) throws IOException {
-        synchronized (this) {
-            if (mFd == null) {
-                throw new IOException("socket not created");
-            }
-            return connectNative(address, port);
-        }
-    }
-
-    private native boolean connectNative(String address, int port);
-
-    /**
-     * Starts an asynchronous (nonblocking) connect to a remote RFCOMM socket.
-     * It takes the address of the device to connect to, as well as the RFCOMM
-     * channel (port). On successful return (return value is true), you need to
-     * call method {@link #waitForAsyncConnect(int) waitForAsyncConnect} to
-     * block for up to a specified number of milliseconds while waiting for the
-     * asyncronous connect to complete.
-     * 
-     * @param address
-     *            of remote device
-     * @param port
-     *            the RFCOMM channel
-     * @return true when the asynchronous connect has successfully started,
-     *         false if there was an error.
-     * @throws IOException
-     *             is you have not called {@link #create() create}
-     * @see #waitForAsyncConnect(int)
-     * @see #getRemainingAsyncConnectWaitingTimeMs()
-     * @see #connect(String, int)
-     */
-    public boolean connectAsync(String address, int port) throws IOException {
-        synchronized (this) {
-            if (mFd == null) {
-                throw new IOException("socket not created");
-            }
-            mIsConnecting = connectAsyncNative(address, port);
-            return mIsConnecting;
-        }
-    }
-
-    private native boolean connectAsyncNative(String address, int port);
-
-    /**
-     * Interrupts an asynchronous connect in progress. This method does nothing
-     * when there is no asynchronous connect in progress.
-     * 
-     * @throws IOException
-     *             if you have not called {@link #create() create}.
-     * @see #connectAsync(String, int)
-     */
-    public void interruptAsyncConnect() throws IOException {
-        synchronized (this) {
-            if (mFd == null) {
-                throw new IOException("socket not created");
-            }
-            if (mIsConnecting) {
-                mIsConnecting = !interruptAsyncConnectNative();
-            }
-        }
-    }
-
-    private native boolean interruptAsyncConnectNative();
-
-    /**
-     * Tells you whether there is an asynchronous connect in progress. This
-     * method returns an undefined value when there is a synchronous connect in
-     * progress.
-     * 
-     * @return true if there is an asyc connect in progress, false otherwise
-     * @see #connectAsync(String, int)
-     */
-    public boolean isConnecting() {
-        return mIsConnecting;
-    }
-
-    /**
-     * Blocks for a specified amount of milliseconds while waiting for an
-     * asynchronous connect to complete. Returns an integer value to indicate
-     * one of the following: the connect succeeded, the connect is still in
-     * progress, or the connect failed. It is possible for this method to block
-     * for less than the time specified by the user, and still return zero
-     * (i.e., async connect is still in progress.) For this reason, if the
-     * return value is zero, you need to call method
-     * {@link #getRemainingAsyncConnectWaitingTimeMs() getRemainingAsyncConnectWaitingTimeMs}
-     * to retrieve the remaining time.
-     * 
-     * @param timeoutMs
-     *            the time to block while waiting for the async connect to
-     *            complete.
-     * @return a positive value if the connect succeeds; zero, if the connect is
-     *         still in progress, and a negative value if the connect failed.
-     * 
-     * @throws IOException
-     * @see #getRemainingAsyncConnectWaitingTimeMs()
-     * @see #connectAsync(String, int)
-     */
-    public int waitForAsyncConnect(int timeoutMs) throws IOException {
-        synchronized (this) {
-            if (mFd == null) {
-                throw new IOException("socket not created");
-            }
-            int ret = waitForAsyncConnectNative(timeoutMs);
-            if (ret != 0) {
-                mIsConnecting = false;
-            }
-            return ret;
-        }
-    }
-
-    private native int waitForAsyncConnectNative(int timeoutMs);
-
-    /**
-     * Returns the number of milliseconds left to wait after the last call to
-     * {@link #waitForAsyncConnect(int) waitForAsyncConnect}.
-     * 
-     * It is possible that waitForAsyncConnect() waits for less than the time
-     * specified by the user, and still returns zero (i.e., async connect is
-     * still in progress.) For this reason, if the return value is zero, you
-     * need to call this method to retrieve the remaining time before you call
-     * waitForAsyncConnect again.
-     * 
-     * @return the remaining timeout in milliseconds.
-     * @see #waitForAsyncConnect(int)
-     * @see #connectAsync(String, int)
-     */
-    public int getRemainingAsyncConnectWaitingTimeMs() {
-        return mTimeoutRemainingMs;
-    }
-
-    /**
-     * Shuts down both directions on a socket.
-     * 
-     * @return true on success, false on failure; if the return value is false,
-     *         the socket might be left in a patially shut-down state (i.e. one
-     *         direction is shut down, but the other is still open.) In this
-     *         case, you should {@link #destroy() destroy} and then
-     *         {@link #create() create} the socket again.
-     * @throws IOException
-     *             is you have not caled {@link #create() create}.
-     * @see #shutdownInput()
-     * @see #shutdownOutput()
-     */
-    public boolean shutdown() throws IOException {
-        synchronized (this) {
-            if (mFd == null) {
-                throw new IOException("socket not created");
-            }
-            if (shutdownNative(true)) {
-                return shutdownNative(false);
-            }
-
-            return false;
-        }
-    }
-
-    /**
-     * Shuts down the input stream of the socket, but leaves the output stream
-     * in its current state.
-     * 
-     * @return true on success, false on failure
-     * @throws IOException
-     *             is you have not called {@link #create() create}
-     * @see #shutdown()
-     * @see #shutdownOutput()
-     */
-    public boolean shutdownInput() throws IOException {
-        synchronized (this) {
-            if (mFd == null) {
-                throw new IOException("socket not created");
-            }
-            return shutdownNative(true);
-        }
-    }
-
-    /**
-     * Shut down the output stream of the socket, but leaves the input stream in
-     * its current state.
-     * 
-     * @return true on success, false on failure
-     * @throws IOException
-     *             is you have not called {@link #create() create}
-     * @see #shutdown()
-     * @see #shutdownInput()
-     */
-    public boolean shutdownOutput() throws IOException {
-        synchronized (this) {
-            if (mFd == null) {
-                throw new IOException("socket not created");
-            }
-            return shutdownNative(false);
-        }
-    }
-
-    private native boolean shutdownNative(boolean shutdownInput);
-
-    /**
-     * Tells you whether a socket is connected to another socket. This could be
-     * for input or output or both.
-     * 
-     * @return true if connected, false otherwise.
-     * @see #isInputConnected()
-     * @see #isOutputConnected()
-     */
-    public boolean isConnected() {
-        return isConnectedNative() > 0;
-    }
-
-    /**
-     * Determines whether input is connected (i.e., whether you can receive data
-     * on this socket.)
-     * 
-     * @return true if input is connected, false otherwise.
-     * @see #isConnected()
-     * @see #isOutputConnected()
-     */
-    public boolean isInputConnected() {
-        return (isConnectedNative() & 1) != 0;
-    }
-
-    /**
-     * Determines whether output is connected (i.e., whether you can send data
-     * on this socket.)
-     * 
-     * @return true if output is connected, false otherwise.
-     * @see #isConnected()
-     * @see #isInputConnected()
-     */
-    public boolean isOutputConnected() {
-        return (isConnectedNative() & 2) != 0;
-    }
-
-    private native int isConnectedNative();
-
-    /**
-     * Binds a listening socket to the local device, or a non-listening socket
-     * to a remote device. The port is automatically selected as the first
-     * available port in the range 12 to 30.
-     *
-     * NOTE: Currently we ignore the device parameter and always bind the socket
-     * to the local device, assuming that it is a listening socket.
-     *
-     * TODO: Use bind(0) in native code to have the kernel select an unused
-     * port.
-     *
-     * @param device
-     *            Bluetooth address of device to bind to (currently ignored).
-     * @return true on success, false on failure
-     * @throws IOException
-     *             if you have not called {@link #create() create}
-     * @see #listen(int)
-     * @see #accept(RfcommSocket,int)
-     */
-    public boolean bind(String device) throws IOException {
-        if (mFd == null) {
-            throw new IOException("socket not created");
-        }
-        for (int port = 12; port <= 30; port++) {
-            if (bindNative(device, port)) {
-                mIsBound = true;
-                return true;
-            }
-        }
-        mIsBound = false;
-        return false;
-    }
-
-    /**
-     * Binds a listening socket to the local device, or a non-listening socket
-     * to a remote device.
-     *
-     * NOTE: Currently we ignore the device parameter and always bind the socket
-     * to the local device, assuming that it is a listening socket.
-     *
-     * @param device
-     *            Bluetooth address of device to bind to (currently ignored).
-     * @param port
-     *            RFCOMM channel to bind socket to.
-     * @return true on success, false on failure
-     * @throws IOException
-     *             if you have not called {@link #create() create}
-     * @see #listen(int)
-     * @see #accept(RfcommSocket,int)
-     */
-    public boolean bind(String device, int port) throws IOException {
-        if (mFd == null) {
-            throw new IOException("socket not created");
-        }
-        mIsBound = bindNative(device, port);
-        return mIsBound;
-    }
-
-    private native boolean bindNative(String device, int port);
-
-    /**
-     * Starts listening for incoming connections on this socket, after it has
-     * been bound to an address and RFCOMM channel with
-     * {@link #bind(String,int) bind}.
-     * 
-     * @param backlog
-     *            the number of pending incoming connections to queue for
-     *            {@link #accept(RfcommSocket, int) accept}.
-     * @return true on success, false on failure
-     * @throws IOException
-     *             if you have not called {@link #create() create} or if the
-     *             socket has not been bound to a device and RFCOMM channel.
-     */
-    public boolean listen(int backlog) throws IOException {
-        if (mFd == null) {
-            throw new IOException("socket not created");
-        }
-        if (!mIsBound) {
-            throw new IOException("socket not bound");
-        }
-        mIsListening = listenNative(backlog);
-        return mIsListening;
-    }
-
-    private native boolean listenNative(int backlog);
-
-    /**
-     * Accepts incoming-connection requests for a listening socket bound to an
-     * RFCOMM channel. The user may provide a time to wait for an incoming
-     * connection.
-     * 
-     * Note that this method may return null (i.e., no incoming connection)
-     * before the user-specified timeout expires. For this reason, on a null
-     * return value, you need to call
-     * {@link #getRemainingAcceptWaitingTimeMs() getRemainingAcceptWaitingTimeMs}
-     * in order to see how much time is left to wait, before you call this
-     * method again.
-     * 
-     * @param newSock
-     *            is set to the new socket that is created as a result of a
-     *            successful accept.
-     * @param timeoutMs
-     *            time (in milliseconds) to block while waiting to an
-     *            incoming-connection request. A negative value is an infinite
-     *            wait.
-     * @return FileDescriptor of newSock on success, null on failure. Failure
-     *         occurs if the timeout expires without a successful connect.
-     * @throws IOException
-     *             if the socket has not been {@link #create() create}ed, is
-     *             not bound, or is not a listening socket.
-     * @see #bind(String, int)
-     * @see #listen(int)
-     * @see #getRemainingAcceptWaitingTimeMs()
-     */
-    public FileDescriptor accept(RfcommSocket newSock, int timeoutMs)
-            throws IOException {
-        synchronized (newSock) {
-            if (mFd == null) {
-                throw new IOException("socket not created");
-            }
-            if (mIsListening == false) {
-                throw new IOException("not listening on socket");
-            }
-            newSock.mFd = acceptNative(newSock, timeoutMs);
-            return newSock.mFd;
-        }
-    }
-
-    /**
-     * Returns the number of milliseconds left to wait after the last call to
-     * {@link #accept(RfcommSocket, int) accept}.
-     * 
-     * Since accept() may return null (i.e., no incoming connection) before the
-     * user-specified timeout expires, you need to call this method in order to
-     * see how much time is left to wait, and wait for that amount of time
-     * before you call accept again.
-     * 
-     * @return the remaining time, in milliseconds.
-     */
-    public int getRemainingAcceptWaitingTimeMs() {
-        return mAcceptTimeoutRemainingMs;
-    }
-
-    private native FileDescriptor acceptNative(RfcommSocket newSock,
-            int timeoutMs);
-
-    /**
-     * Get the port (rfcomm channel) associated with this socket.
-     *
-     * This is only valid if the port has been set via a successful call to
-     * {@link #bind(String, int)}, {@link #connect(String, int)}
-     * or {@link #connectAsync(String, int)}. This can be checked
-     * with {@link #isListening()} and {@link #isConnected()}.
-     * @return Port (rfcomm channel)
-     */
-    public int getPort() throws IOException {
-        if (mFd == null) {
-            throw new IOException("socket not created");
-        }
-        if (!mIsListening && !isConnected()) {
-            throw new IOException("not listening or connected on socket");
-        }
-        return mPort;
-    }
-
-    /**
-     * Return true if this socket is listening ({@link #listen(int)}
-     * has been called successfully).
-     */
-    public boolean isListening() {
-        return mIsListening;
-    }
-}
diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java
index 6b50405..bffd829 100644
--- a/core/java/android/content/ContentProvider.java
+++ b/core/java/android/content/ContentProvider.java
@@ -377,9 +377,10 @@
      * Example client call:<p>
      * <pre>// Request a specific record.
      * Cursor managedCursor = managedQuery(
-                Contacts.People.CONTENT_URI.addId(2),
+                ContentUris.withAppendedId(Contacts.People.CONTENT_URI, 2),
                 projection,    // Which columns to return.
                 null,          // WHERE clause.
+                null,          // WHERE clause value substitution
                 People.NAME + " ASC");   // Sort order.</pre>
      * Example implementation:<p>
      * <pre>// SQLiteQueryBuilder is a helper class that creates the
@@ -408,15 +409,18 @@
         return c;</pre>
      *
      * @param uri The URI to query. This will be the full URI sent by the client;
-     * if the client is requesting a specific record, the URI will end in a record number
-     * that the implementation should parse and add to a WHERE or HAVING clause, specifying
-     * that _id value.
+     *      if the client is requesting a specific record, the URI will end in a record number
+     *      that the implementation should parse and add to a WHERE or HAVING clause, specifying
+     *      that _id value.
      * @param projection The list of columns to put into the cursor. If
      *      null all columns are included.
      * @param selection A selection criteria to apply when filtering rows.
      *      If null then all rows are included.
+     * @param selectionArgs You may include ?s in selection, which will be replaced by
+     *      the values from selectionArgs, in order that they appear in the selection.
+     *      The values will be bound as Strings.
      * @param sortOrder How the rows in the cursor should be sorted.
-     *        If null then the provider is free to define the sort order.
+     *      If null then the provider is free to define the sort order.
      * @return a Cursor or null.
      */
     public abstract Cursor query(Uri uri, String[] projection,
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index c62d66b..dfda09c 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -75,10 +75,10 @@
  * <p>Some examples of action/data pairs are:</p>
  *
  * <ul>
- *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/1</i></b> -- Display
+ *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
  *     information about the person whose identifier is "1".</p>
  *   </li>
- *   <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/1</i></b> -- Display
+ *   <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
  *     the phone dialer with the person filled in.</p>
  *   </li>
  *   <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
@@ -89,10 +89,10 @@
  *   <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
  *     the phone dialer with the given number filled in.</p>
  *   </li>
- *   <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/1</i></b> -- Edit
+ *   <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
  *     information about the person whose identifier is "1".</p>
  *   </li>
- *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/</i></b> -- Display
+ *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
  *     a list of people, which the user can browse through.  This example is a
  *     typical top-level entry into the Contacts application, showing you the
  *     list of people. Selecting a particular person to view would result in a
@@ -156,7 +156,7 @@
  * defined in the Intent class, but applications can also define their own.
  * These strings use java style scoping, to ensure they are unique -- for
  * example, the standard {@link #ACTION_VIEW} is called
- * "android.app.action.VIEW".</p>
+ * "android.intent.action.VIEW".</p>
  *
  * <p>Put together, the set of actions, data types, categories, and extra data
  * defines a language for the system allowing for the expression of phrases
@@ -347,7 +347,7 @@
  *     <li> <p><b>{ action=android.app.action.MAIN,
  *         category=android.app.category.LAUNCHER }</b> is the actual intent
  *         used by the Launcher to populate its top-level list.</p>
- *     <li> <p><b>{ action=android.app.action.VIEW
+ *     <li> <p><b>{ action=android.intent.action.VIEW
  *          data=content://com.google.provider.NotePad/notes }</b>
  *         displays a list of all the notes under
  *         "content://com.google.provider.NotePad/notes", which
@@ -399,7 +399,7 @@
  * NoteEditor activity:</p>
  *
  * <ul>
- *     <li> <p><b>{ action=android.app.action.VIEW
+ *     <li> <p><b>{ action=android.intent.action.VIEW
  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
  *         shows the user the content of note <var>{ID}</var>.</p>
  *     <li> <p><b>{ action=android.app.action.EDIT
@@ -1394,7 +1394,8 @@
      * by the system.
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    public static final String ACTION_POWER_DISCONNECTED = "android.intent.action.ACTION_POWER_DISCONNECTED";
+    public static final String ACTION_POWER_DISCONNECTED =
+            "android.intent.action.ACTION_POWER_DISCONNECTED";    
     /**
      * Broadcast Action:  Device is shutting down.
      * This is broadcast when the device is being shut down (completely turned
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 5f44cc9..cbf8410 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -93,7 +93,8 @@
     
     /**
      * The kind of keyboard attached to the device.
-     * One of: {@link #KEYBOARD_QWERTY}, {@link #KEYBOARD_12KEY}.
+     * One of: {@link #KEYBOARD_NOKEYS}, {@link #KEYBOARD_QWERTY},
+     * {@link #KEYBOARD_12KEY}.
      */
     public int keyboard;
     
@@ -132,8 +133,8 @@
     
     /**
      * The kind of navigation method available on the device.
-     * One of: {@link #NAVIGATION_DPAD}, {@link #NAVIGATION_TRACKBALL}, 
-     * {@link #NAVIGATION_WHEEL}. 
+     * One of: {@link #NAVIGATION_NONAV}, {@link #NAVIGATION_DPAD},
+     * {@link #NAVIGATION_TRACKBALL}, {@link #NAVIGATION_WHEEL}.
      */
     public int navigation;
     
diff --git a/core/java/android/database/sqlite/SQLiteQueryBuilder.java b/core/java/android/database/sqlite/SQLiteQueryBuilder.java
index 8a63919..af54a71 100644
--- a/core/java/android/database/sqlite/SQLiteQueryBuilder.java
+++ b/core/java/android/database/sqlite/SQLiteQueryBuilder.java
@@ -355,23 +355,26 @@
             String groupBy, String having, String sortOrder, String limit) {
         String[] projection = computeProjection(projectionIn);
 
+        StringBuilder where = new StringBuilder();
+
         if (mWhereClause.length() > 0) {
-            mWhereClause.append(')');
+            where.append(mWhereClause.toString());
+            where.append(')');
         }
 
         // Tack on the user's selection, if present.
         if (selection != null && selection.length() > 0) {
             if (mWhereClause.length() > 0) {
-                mWhereClause.append(" AND ");
+                where.append(" AND ");
             }
 
-            mWhereClause.append('(');
-            mWhereClause.append(selection);
-            mWhereClause.append(')');
+            where.append('(');
+            where.append(selection);
+            where.append(')');
         }
 
         return buildQueryString(
-                mDistinct, mTables, projection, mWhereClause.toString(),
+                mDistinct, mTables, projection, where.toString(),
                 groupBy, having, sortOrder, limit);
     }
 
diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java
index 421d013..298be3b 100644
--- a/core/java/android/net/Uri.java
+++ b/core/java/android/net/Uri.java
@@ -374,7 +374,7 @@
     /**
      * Creates a Uri which parses the given encoded URI string.
      *
-     * @param uriString an RFC 3296-compliant, encoded URI
+     * @param uriString an RFC 2396-compliant, encoded URI
      * @throws NullPointerException if uriString is null
      * @return Uri for this given uri string
      */
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index afe219c..b54ad5d 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -73,7 +73,7 @@
         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/calls";
 
         /**
-         * The type of the the phone number.
+         * The type of the call (incoming, outgoing or missed).
          * <P>Type: INTEGER (int)</P>
          */
         public static final String TYPE = "type";
diff --git a/core/java/android/provider/Contacts.java b/core/java/android/provider/Contacts.java
index 84fe184..35463cf 100644
--- a/core/java/android/provider/Contacts.java
+++ b/core/java/android/provider/Contacts.java
@@ -1229,7 +1229,7 @@
      */
     public interface OrganizationColumns {
         /**
-         * The type of the the phone number.
+         * The type of the organizations.
          * <P>Type: INTEGER (one of the constants below)</P>
          */
         public static final String TYPE = "type";
diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java
index 4c58e0d..790fe5c 100644
--- a/core/java/android/provider/Downloads.java
+++ b/core/java/android/provider/Downloads.java
@@ -63,7 +63,7 @@
      * that had initiated a download when that download completes. The
      * download's content: uri is specified in the intent's data.
      */
-    public static final String DOWNLOAD_COMPLETED_ACTION =
+    public static final String ACTION_DOWNLOAD_COMPLETED =
             "android.intent.action.DOWNLOAD_COMPLETED";
 
     /**
@@ -76,7 +76,7 @@
      * Note: this is not currently sent for downloads that have completed
      * successfully.
      */
-    public static final String NOTIFICATION_CLICKED_ACTION =
+    public static final String ACTION_NOTIFICATION_CLICKED =
             "android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED";
 
     /**
@@ -84,14 +84,14 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init/Read</P>
      */
-    public static final String URI = "uri";
+    public static final String COLUMN_URI = "uri";
 
     /**
      * The name of the column containing application-specific data.
      * <P>Type: TEXT</P>
      * <P>Owner can Init/Read/Write</P>
      */
-    public static final String APP_DATA = "entity";
+    public static final String COLUMN_APP_DATA = "entity";
 
     /**
      * The name of the column containing the flags that indicates whether
@@ -104,7 +104,7 @@
      * <P>Type: BOOLEAN</P>
      * <P>Owner can Init</P>
      */
-    public static final String NO_INTEGRITY = "no_integrity";
+    public static final String COLUMN_NO_INTEGRITY = "no_integrity";
 
     /**
      * The name of the column containing the filename that the initiating
@@ -113,7 +113,7 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init</P>
      */
-    public static final String FILENAME_HINT = "hint";
+    public static final String COLUMN_FILE_NAME_HINT = "hint";
 
     /**
      * The name of the column containing the filename where the downloaded data
@@ -128,7 +128,7 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init/Read</P>
      */
-    public static final String MIMETYPE = "mimetype";
+    public static final String COLUMN_MIME_TYPE = "mimetype";
 
     /**
      * The name of the column containing the flag that controls the destination
@@ -136,7 +136,7 @@
      * <P>Type: INTEGER</P>
      * <P>Owner can Init</P>
      */
-    public static final String DESTINATION = "destination";
+    public static final String COLUMN_DESTINATION = "destination";
 
     /**
      * The name of the column containing the flags that controls whether the
@@ -145,7 +145,7 @@
      * <P>Type: INTEGER</P>
      * <P>Owner can Init/Read/Write</P>
      */
-    public static final String VISIBILITY = "visibility";
+    public static final String COLUMN_VISIBILITY = "visibility";
 
     /**
      * The name of the column containing the current control state  of the download.
@@ -154,7 +154,7 @@
      * <P>Type: INTEGER</P>
      * <P>Owner can Read</P>
      */
-    public static final String CONTROL = "control";
+    public static final String COLUMN_CONTROL = "control";
 
     /**
      * The name of the column containing the current status of the download.
@@ -163,7 +163,7 @@
      * <P>Type: INTEGER</P>
      * <P>Owner can Read</P>
      */
-    public static final String STATUS = "status";
+    public static final String COLUMN_STATUS = "status";
 
     /**
      * The name of the column containing the date at which some interesting
@@ -172,7 +172,7 @@
      * <P>Type: BIGINT</P>
      * <P>Owner can Read</P>
      */
-    public static final String LAST_MODIFICATION = "lastmod";
+    public static final String COLUMN_LAST_MODIFICATION = "lastmod";
 
     /**
      * The name of the column containing the package name of the application
@@ -181,7 +181,7 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init/Read</P>
      */
-    public static final String NOTIFICATION_PACKAGE = "notificationpackage";
+    public static final String COLUMN_NOTIFICATION_PACKAGE = "notificationpackage";
 
     /**
      * The name of the column containing the component name of the class that
@@ -191,7 +191,7 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init/Read</P>
      */
-    public static final String NOTIFICATION_CLASS = "notificationclass";
+    public static final String COLUMN_NOTIFICATION_CLASS = "notificationclass";
 
     /**
      * If extras are specified when requesting a download they will be provided in the intent that
@@ -199,7 +199,7 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init</P>
      */
-    public static final String NOTIFICATION_EXTRAS = "notificationextras";
+    public static final String COLUMN_NOTIFICATION_EXTRAS = "notificationextras";
 
     /**
      * The name of the column contain the values of the cookie to be used for
@@ -208,7 +208,7 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init</P>
      */
-    public static final String COOKIE_DATA = "cookiedata";
+    public static final String COLUMN_COOKIE_DATA = "cookiedata";
 
     /**
      * The name of the column containing the user agent that the initiating
@@ -216,7 +216,7 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init</P>
      */
-    public static final String USER_AGENT = "useragent";
+    public static final String COLUMN_USER_AGENT = "useragent";
 
     /**
      * The name of the column containing the referer (sic) that the initiating
@@ -224,7 +224,7 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init</P>
      */
-    public static final String REFERER = "referer";
+    public static final String COLUMN_REFERER = "referer";
 
     /**
      * The name of the column containing the total size of the file being
@@ -232,7 +232,7 @@
      * <P>Type: INTEGER</P>
      * <P>Owner can Read</P>
      */
-    public static final String TOTAL_BYTES = "total_bytes";
+    public static final String COLUMN_TOTAL_BYTES = "total_bytes";
 
     /**
      * The name of the column containing the size of the part of the file that
@@ -240,7 +240,7 @@
      * <P>Type: INTEGER</P>
      * <P>Owner can Read</P>
      */
-    public static final String CURRENT_BYTES = "current_bytes";
+    public static final String COLUMN_CURRENT_BYTES = "current_bytes";
 
     /**
      * The name of the column where the initiating application can provide the
@@ -252,7 +252,7 @@
      * <P>Type: INTEGER</P>
      * <P>Owner can Init</P>
      */
-    public static final String OTHER_UID = "otheruid";
+    public static final String COLUMN_OTHER_UID = "otheruid";
 
     /**
      * The name of the column where the initiating application can provided the
@@ -261,7 +261,7 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init/Read/Write</P>
      */
-    public static final String TITLE = "title";
+    public static final String COLUMN_TITLE = "title";
 
     /**
      * The name of the column where the initiating application can provide the
@@ -270,7 +270,7 @@
      * <P>Type: TEXT</P>
      * <P>Owner can Init/Read/Write</P>
      */
-    public static final String DESCRIPTION = "description";
+    public static final String COLUMN_DESCRIPTION = "description";
 
     /*
      * Lists the destinations that an application can specify for a download.
diff --git a/core/java/android/text/InputType.java b/core/java/android/text/InputType.java
index d50684a..41d5b84 100644
--- a/core/java/android/text/InputType.java
+++ b/core/java/android/text/InputType.java
@@ -20,7 +20,25 @@
 
 /**
  * Bit definitions for an integer defining the basic content type of text
- * held in an {@link Editable} object.
+ * held in an {@link Editable} object. Supported classes may be combined
+ * with variations and flags to indicate desired behaviors.
+ *
+ * <h3>Examples</h3>
+ *
+ * <dl>
+ * <dt>A password field with with the password visible to the user:
+ * <dd>inputType = TYPE_CLASS_TEXT |
+ *     TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
+ *
+ * <dt>A multi-line postal address with automatic capitalization:
+ * <dd>inputType = TYPE_CLASS_TEXT |
+ *     TYPE_TEXT_VARIATION_POSTAL_ADDRESS |
+ *     TYPE_TEXT_FLAG_MULTI_LINE
+ *
+ * <dt>A time field:
+ * <dd>inputType = TYPE_CLASS_DATETIME |
+ *     TYPE_DATETIME_VARIATION_TIME
+ * </dl>
  */
 public interface InputType {
     /**
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 9cf7092..4546572 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -32,8 +32,9 @@
 import android.util.AttributeSet;
 import android.util.Config;
 import android.util.Log;
-import java.util.ArrayList;
 
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
 import java.util.concurrent.locks.ReentrantLock;
 import java.lang.ref.WeakReference;
 
diff --git a/core/java/android/webkit/CookieSyncManager.java b/core/java/android/webkit/CookieSyncManager.java
index 8d66529..aa6c76b 100644
--- a/core/java/android/webkit/CookieSyncManager.java
+++ b/core/java/android/webkit/CookieSyncManager.java
@@ -24,30 +24,39 @@
 import java.util.Iterator;
 
 /**
- * The class CookieSyncManager is used to synchronize the browser cookies
- * between RAM and FLASH. To get the best performance, browser cookie is saved
- * in RAM. We use a separate thread to sync the cookies between RAM and FLASH on
- * a timer base.
+ * The CookieSyncManager is used to synchronize the browser cookie store
+ * between RAM and permanent storage. To get the best performance, browser cookies are
+ * saved in RAM. A separate thread saves the cookies between, driven by a timer.
  * <p>
+ *
  * To use the CookieSyncManager, the host application has to call the following
- * when the application starts.
+ * when the application starts:
  * <p>
- * CookieSyncManager.createInstance(context)
+ *
+ * <pre class="prettyprint">CookieSyncManager.createInstance(context)</pre><p>
+ *
+ * To set up for sync, the host application has to call<p>
+ * <pre class="prettyprint">CookieSyncManager.getInstance().startSync()</pre><p>
+ *
+ * in Activity.onResume(), and call
  * <p>
- * To set up for sync, the host application has to call
- * <p>
- * CookieSyncManager.getInstance().startSync()
- * <p>
- * in its Activity.onResume(), and call
- * <p>
+ *
+ * <pre class="prettyprint">
  * CookieSyncManager.getInstance().stopSync()
- * <p>
- * in its Activity.onStop().
- * <p>
+ * </pre><p>
+ *
+ * in Activity.onPause().<p>
+ *
  * To get instant sync instead of waiting for the timer to trigger, the host can
  * call
  * <p>
- * CookieSyncManager.getInstance().sync()
+ * <pre class="prettyprint">CookieSyncManager.getInstance().sync()</pre><p>
+ *
+ * The sync interval is 5 minutes, so you will want to force syncs
+ * manually anyway, for instance in {@link
+ * WebViewClient#onPageFinished}. Note that even sync() happens
+ * asynchronously, so don't do it just as your activity is shutting
+ * down.
  */
 public final class CookieSyncManager extends WebSyncManager {
 
@@ -90,7 +99,7 @@
     }
 
     /**
-     * Package level api, called from CookieManager Get all the cookies which
+     * Package level api, called from CookieManager. Get all the cookies which
      * matches a given base domain.
      * @param domain
      * @return A list of Cookie
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index a038b55..51c4293 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -130,9 +130,13 @@
     private boolean mSyncPending = false;
     // Custom handler that queues messages until the WebCore thread is active.
     private final EventHandler mEventHandler;
+
     // Private settings so we don't have to go into native code to
     // retrieve the values. After setXXX, postSync() needs to be called.
-    // XXX: The default values need to match those in WebSettings.cpp
+    //
+    // The default values need to match those in WebSettings.cpp
+    // If the defaults change, please also update the JavaDocs so developers
+    // know what they are.
     private LayoutAlgorithm mLayoutAlgorithm = LayoutAlgorithm.NARROW_COLUMNS;
     private Context         mContext;
     private TextSize        mTextSize = TextSize.NORMAL;
@@ -511,24 +515,21 @@
     }
 
     /**
-     * Tell the WebView to use the double tree rendering algorithm.
-     * @param use True if the WebView is to use double tree rendering, false
-     *            otherwise.
+     * @deprecated This setting controlled a rendering optimization
+     * that is no longer present. Setting it now has no effect.
      */
+    @Deprecated
     public synchronized void setUseDoubleTree(boolean use) {
-        if (mUseDoubleTree != use) {
-            mUseDoubleTree = use;
-            postSync();
-        }
+        return;
     }
 
     /**
-     * Return true if the WebView is using the double tree rendering algorithm.
-     * @return True if the WebView is using the double tree rendering
-     *         algorithm.
+     * @deprecated This setting controlled a rendering optimization
+     * that is no longer present. Setting it now has no effect.
      */
+    @Deprecated
     public synchronized boolean getUseDoubleTree() {
-        return mUseDoubleTree;
+        return false;
     }
 
     /**
@@ -633,7 +634,7 @@
     }
 
     /**
-     * Return the current layout algorithm.
+     * Return the current layout algorithm. The default is NARROW_COLUMNS.
      * @return LayoutAlgorithm enum value describing the layout algorithm
      *         being used.
      * @see WebSettings.LayoutAlgorithm
@@ -654,7 +655,7 @@
     }
 
     /**
-     * Get the standard font family name.
+     * Get the standard font family name. The default is "sans-serif".
      * @return The standard font family name as a string.
      */
     public synchronized String getStandardFontFamily() {
@@ -673,7 +674,7 @@
     }
 
     /**
-     * Get the fixed font family name.
+     * Get the fixed font family name. The default is "monospace".
      * @return The fixed font family name as a string.
      */
     public synchronized String getFixedFontFamily() {
@@ -700,7 +701,7 @@
     }
 
     /**
-     * Set the serif font family name.
+     * Set the serif font family name. The default is "sans-serif".
      * @param font A font family name.
      */
     public synchronized void setSerifFontFamily(String font) {
@@ -711,7 +712,7 @@
     }
 
     /**
-     * Get the serif font family name.
+     * Get the serif font family name. The default is "serif".
      * @return The serif font family name as a string.
      */
     public synchronized String getSerifFontFamily() {
@@ -730,7 +731,7 @@
     }
 
     /**
-     * Get the cursive font family name.
+     * Get the cursive font family name. The default is "cursive".
      * @return The cursive font family name as a string.
      */
     public synchronized String getCursiveFontFamily() {
@@ -749,7 +750,7 @@
     }
 
     /**
-     * Get the fantasy font family name.
+     * Get the fantasy font family name. The default is "fantasy".
      * @return The fantasy font family name as a string.
      */
     public synchronized String getFantasyFontFamily() {
@@ -770,7 +771,7 @@
     }
 
     /**
-     * Get the minimum font size.
+     * Get the minimum font size. The default is 8.
      * @return A non-negative integer between 1 and 72.
      */
     public synchronized int getMinimumFontSize() {
@@ -791,7 +792,7 @@
     }
 
     /**
-     * Get the minimum logical font size.
+     * Get the minimum logical font size. The default is 8.
      * @return A non-negative integer between 1 and 72.
      */
     public synchronized int getMinimumLogicalFontSize() {
@@ -812,7 +813,7 @@
     }
 
     /**
-     * Get the default font size.
+     * Get the default font size. The default is 16.
      * @return A non-negative integer between 1 and 72.
      */
     public synchronized int getDefaultFontSize() {
@@ -833,7 +834,7 @@
     }
 
     /**
-     * Get the default fixed font size.
+     * Get the default fixed font size. The default is 16.
      * @return A non-negative integer between 1 and 72.
      */
     public synchronized int getDefaultFixedFontSize() {
@@ -853,6 +854,7 @@
 
     /**
      * Return true if the WebView will load image resources automatically.
+     * The default is true.
      * @return True if the WebView loads images automatically.
      */
     public synchronized boolean getLoadsImagesAutomatically() {
@@ -872,16 +874,16 @@
     }
 
     /**
-     * Return true if the WebView will block network image.
+     * Return true if the WebView will block network image. The default is false.
      * @return True if the WebView blocks network image.
      */
     public synchronized boolean getBlockNetworkImage() {
         return mBlockNetworkImage;
     }
-    
+
     /**
      * @hide
-     * Tell the WebView to block all network load requests. 
+     * Tell the WebView to block all network load requests.
      * @param flag True if the WebView should block all network loads
      */
     public synchronized void setBlockNetworkLoads(boolean flag) {
@@ -894,13 +896,14 @@
     /**
      * @hide
      * Return true if the WebView will block all network loads.
+     * The default is false.
      * @return True if the WebView blocks all network loads.
      */
     public synchronized boolean getBlockNetworkLoads() {
         return mBlockNetworkLoads;
     }
-    
-    
+
+
     private void verifyNetworkAccess() {
         if (!mBlockNetworkLoads) {
             if (mContext.checkPermission("android.permission.INTERNET", 
@@ -948,7 +951,7 @@
     }
 
     /**
-     * Return true if javascript is enabled.
+     * Return true if javascript is enabled. <b>Note: The default is false.</b>
      * @return True if javascript is enabled.
      */
     public synchronized boolean getJavaScriptEnabled() {
@@ -985,7 +988,8 @@
     }
 
     /**
-     * Return true if javascript can open windows automatically.
+     * Return true if javascript can open windows automatically. The default
+     * is false.
      * @return True if javascript can open windows automatically during
      *         window.open().
      */
@@ -1005,7 +1009,7 @@
     }
 
     /**
-     * Get the default text encoding name.
+     * Get the default text encoding name. The default is "Latin-1".
      * @return The default text encoding name as a string.
      */
     public synchronized String getDefaultTextEncodingName() {
@@ -1094,8 +1098,8 @@
 
     /**
      * Set the priority of the Render thread. Unlike the other settings, this
-     * one only needs to be called once per process.
-     * 
+     * one only needs to be called once per process. The default is NORMAL.
+     *
      * @param priority RenderPriority, can be normal, high or low.
      */
     public synchronized void setRenderPriority(RenderPriority priority) {
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 6936435..2892051 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -96,7 +96,104 @@
  * in a WebView, you must add the <var>INTERNET</var> permissions to your 
  * Android Manifest file:</p>
  * <pre>&lt;uses-permission android:name="android.permission.INTERNET" /></pre>
+ *
  * <p>This must be a child of the <code>&lt;manifest></code> element.</p>
+ *
+ * <h3>Basic usage</h3>
+ *
+ * <p>By default, a WebView provides no browser-like widgets, does not
+ * enable JavaScript and errors will be ignored. If your goal is only
+ * to display some HTML as a part of your UI, this is probably fine;
+ * the user won't need to interact with the web page beyond reading
+ * it, and the web page won't need to interact with the user. If you
+ * actually want a fully blown web browser, then you probably want to
+ * invoke the Browser application with your URL rather than show it
+ * with a WebView. See {@link android.content.Intent} for more information.</p>
+ *
+ * <pre class="prettyprint">
+ * WebView webview = new WebView(this);
+ * setContentView(webview);
+ *
+ * // Simplest usage: note that an exception will NOT be thrown
+ * // if there is an error loading this page (see below).
+ * webview.loadUrl("http://slashdot.org/");
+ *
+ * // Of course you can also load from any string:
+ * String summary = "&lt;html>&lt;body>You scored &lt;b>192</b> points.&lt;/body>&lt;/html>";
+ * webview.loadData(summary, "text/html", "utf-8");
+ * // ... although note that there are restrictions on what this HTML can do.
+ * // See the JavaDocs for loadData and loadDataWithBaseUrl for more info.
+ * </pre>
+ *
+ * <p>A WebView has several customization points where you can add your
+ * own behavior. These are:</p>
+ *
+ * <ul>
+ *   <li>Creating and setting a {@link android.webkit.WebChromeClient} subclass.
+ *       This class is called when something that might impact a
+ *       browser UI happens, for instance, progress updates and
+ *       JavaScript alerts are sent here.
+ *   </li>
+ *   <li>Creating and setting a {@link android.webkit.WebViewClient} subclass.
+ *       It will be called when things happen that impact the
+ *       rendering of the content, eg, errors or form submissions. You
+ *       can also intercept URL loading here.</li>
+ *   <li>Via the {@link android.webkit.WebSettings} class, which contains
+ *       miscellaneous configuration. </li>
+ *   <li>With the {@link android.webkit.WebView#addJavascriptInterface} method.
+ *       This lets you bind Java objects into the WebView so they can be
+ *       controlled from the web pages JavaScript.</li>
+ * </ul>
+ *
+ * <p>Here's a more complicated example, showing error handling,
+ *    settings, and progress notification:</p>
+ *
+ * <pre class="prettyprint">
+ * // Let's display the progress in the activity title bar, like the
+ * // browser app does.
+ * getWindow().requestFeature(Window.FEATURE_PROGRESS);
+ *
+ * webview.getSettings().setJavaScriptEnabled(true);
+ *
+ * final Activity activity = this;
+ * webview.setWebChromeClient(new WebChromeClient() {
+ *   public void onProgressChanged(WebView view, int progress) {
+ *     // Activities and WebViews measure progress with different scales.
+ *     // The progress meter will automatically disappear when we reach 100%
+ *     activity.setProgress(progress * 1000);
+ *   }
+ * });
+ * webview.setWebViewClient(new WebViewClient() {
+ *   public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
+ *     Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
+ *   }
+ * });
+ *
+ * webview.loadUrl("http://slashdot.org/");
+ * </pre>
+ *
+ * <h3>Cookie and window management</h3>
+ *
+ * <p>For obvious security reasons, your application has its own
+ * cache, cookie store etc - it does not share the Browser
+ * applications data. Cookies are managed on a separate thread, so
+ * operations like index building don't block the UI
+ * thread. Follow the instructions in {@link android.webkit.CookieSyncManager}
+ * if you want to use cookies in your application.
+ * </p>
+ *
+ * <p>By default, requests by the HTML to open new windows are
+ * ignored. This is true whether they be opened by JavaScript or by
+ * the target attribute on a link. You can customize your
+ * WebChromeClient to provide your own behaviour for opening multiple windows,
+ * and render them in whatever manner you want.</p>
+ *
+ * <p>Standard behavior for an Activity is to be destroyed and
+ * recreated when the devices orientation is changed. This will cause
+ * the WebView to reload the current page. If you don't want that, you
+ * can set your Activity to handle the orientation and keyboardHidden
+ * changes, and then just leave the WebView alone. It'll automatically
+ * re-orient itself as appropriate.</p>
  */
 public class WebView extends AbsoluteLayout 
         implements ViewTreeObserver.OnGlobalFocusChangeListener,
@@ -1887,14 +1984,15 @@
     }
 
     /**
-     * Clear the resource cache. This will cause resources to be re-downloaded
-     * if accessed again.
-     * <p>
-     * Note: this really needs to be a static method as it clears cache for all
-     * WebView. But we need mWebViewCore to send message to WebCore thread, so
-     * we can't make this static.
+     * Clear the resource cache. Note that the cache is per-application, so
+     * this will clear the cache for all WebViews used.
+     *
+     * @param includeDiskFiles If false, only the RAM cache is cleared.
      */
     public void clearCache(boolean includeDiskFiles) {
+        // Note: this really needs to be a static method as it clears cache for all
+        // WebView. But we need mWebViewCore to send message to WebCore thread, so
+        // we can't make this static.
         mWebViewCore.sendMessage(EventHub.CLEAR_CACHE,
                 includeDiskFiles ? 1 : 0, 0);
     }
diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java
index 04cb8a0..f92eb99 100644
--- a/core/java/android/widget/AbsSeekBar.java
+++ b/core/java/android/widget/AbsSeekBar.java
@@ -320,11 +320,6 @@
         
         final int max = getMax();
         progress += scale * max;
-        if (progress < 0) {
-            progress = 0;
-        } else if (progress > max) {
-            progress = max;
-        }
         
         setProgress((int) progress, true);
     }
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index f8a6f89..515b581 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -3285,11 +3285,12 @@
 
     /**
      * Returns the checked state of the specified position. The result is only
-     * valid if the choice mode has not been set to {@link #CHOICE_MODE_SINGLE}
+     * valid if the choice mode has been set to {@link #CHOICE_MODE_SINGLE}
      * or {@link #CHOICE_MODE_MULTIPLE}.
      *
      * @param position The item whose checked state to return
-     * @return The item's checked state
+     * @return The item's checked state or <code>false</code> if choice mode
+     *         is invalid
      *
      * @see #setChoiceMode(int)
      */
@@ -3303,7 +3304,7 @@
 
     /**
      * Returns the currently checked item. The result is only valid if the choice
-     * mode has not been set to {@link #CHOICE_MODE_SINGLE}.
+     * mode has been set to {@link #CHOICE_MODE_SINGLE}.
      *
      * @return The position of the currently checked item or
      *         {@link #INVALID_POSITION} if nothing is selected
@@ -3320,10 +3321,12 @@
 
     /**
      * Returns the set of checked items in the list. The result is only valid if
-     * the choice mode has not been set to {@link #CHOICE_MODE_SINGLE}.
+     * the choice mode has not been set to {@link #CHOICE_MODE_NONE}.
      *
      * @return  A SparseBooleanArray which will return true for each call to
-     *          get(int position) where position is a position in the list.
+     *          get(int position) where position is a position in the list,
+     *          or <code>null</code> if the choice mode is set to
+     *          {@link #CHOICE_MODE_NONE}.
      */
     public SparseBooleanArray getCheckedItemPositions() {
         if (mChoiceMode != CHOICE_MODE_NONE) {
diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java
index c9ace0a..381641f 100644
--- a/core/java/android/widget/Scroller.java
+++ b/core/java/android/widget/Scroller.java
@@ -17,6 +17,7 @@
 package android.widget;
 
 import android.content.Context;
+import android.hardware.SensorManager;
 import android.view.ViewConfiguration;
 import android.view.animation.AnimationUtils;
 import android.view.animation.Interpolator;
@@ -79,9 +80,9 @@
         mFinished = true;
         mInterpolator = interpolator;
         float ppi = context.getResources().getDisplayMetrics().density * 160.0f;
-        mDeceleration = 9.8f   // g (m/s^2)
-                      * 39.37f // inch/meter
-                      * ppi    // pixels per inch
+        mDeceleration = SensorManager.GRAVITY_EARTH   // g (m/s^2)
+                      * 39.37f                        // inch/meter
+                      * ppi                           // pixels per inch
                       * ViewConfiguration.getScrollFriction();
     }
     
@@ -347,7 +348,11 @@
     }
     
     /**
-     * 
+     * Stops the animation. Contrary to {@link #forceFinished(boolean)},
+     * aborting the animating cause the scroller to move to the final x and y
+     * position
+     *
+     * @see #forceFinished(boolean)
      */
     public void abortAnimation() {
         mCurrX = mFinalX;
@@ -356,10 +361,12 @@
     }
     
     /**
-     * Extend the scroll animation. This allows a running animation to 
-     * scroll further and longer, when used with setFinalX() or setFinalY().
+     * Extend the scroll animation. This allows a running animation to scroll
+     * further and longer, when used with {@link #setFinalX(int)} or {@link #setFinalY(int)}.
      *
      * @param extend Additional time to scroll in milliseconds.
+     * @see #setFinalX(int)
+     * @see #setFinalY(int)
      */
     public void extendDuration(int extend) {
         int passed = timePassed();
@@ -367,18 +374,37 @@
         mDurationReciprocal = 1.0f / (float)mDuration;
         mFinished = false;
     }
-    
+
+    /**
+     * Returns the time elapsed since the beginning of the scrolling.
+     *
+     * @return The elapsed time in milliseconds.
+     */
     public int timePassed() {
         return (int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
     }
-    
+
+    /**
+     * Sets the final position (X) for this scroller.
+     *
+     * @param newX The new X offset as an absolute distance from the origin.
+     * @see #extendDuration(int)
+     * @see #setFinalY(int)
+     */
     public void setFinalX(int newX) {
         mFinalX = newX;
         mDeltaX = mFinalX - mStartX;
         mFinished = false;
     }
 
-   public void setFinalY(int newY) {
+    /**
+     * Sets the final position (Y) for this scroller.
+     *
+     * @param newY The new Y offset as an absolute distance from the origin.
+     * @see #extendDuration(int)
+     * @see #setFinalX(int)
+     */
+    public void setFinalY(int newY) {
         mFinalY = newY;
         mDeltaY = mFinalY - mStartY;
         mFinished = false;
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 260799e..aed2d5a 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -5769,7 +5769,7 @@
      * Causes words in the text that are longer than the view is wide
      * to be ellipsized instead of broken in the middle.  You may also
      * want to {@link #setSingleLine} or {@link #setHorizontallyScrolling}
-     * to constrain the text toa single line.  Use <code>null</code>
+     * to constrain the text to a single line.  Use <code>null</code>
      * to turn off ellipsizing.
      *
      * @attr ref android.R.styleable#TextView_ellipsize
diff --git a/core/java/android/widget/TwoLineListItem.java b/core/java/android/widget/TwoLineListItem.java
index eab6f2d..9a72980 100644
--- a/core/java/android/widget/TwoLineListItem.java
+++ b/core/java/android/widget/TwoLineListItem.java
@@ -36,7 +36,8 @@
  * that can be displayed when a TwoLineListItem has focus. Android supplies a 
  * {@link android.R.layout#two_line_list_item standard layout resource for TwoLineListView} 
  * (which does not include a selected item icon), but you can design your own custom XML
- * layout for this object.
+ * layout for this object as shown in the Phone Application.
+ * (packages/apps/Phone/res/layout/dialer_list_item.xml)
  * 
  * @attr ref android.R.styleable#TwoLineListItem_mode
  */
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 888cb11..c8c6114 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -104,11 +104,10 @@
 	android_util_FileObserver.cpp \
 	android/opengl/poly_clip.cpp.arm \
 	android/opengl/util.cpp.arm \
-	android_bluetooth_Database.cpp \
 	android_bluetooth_HeadsetBase.cpp \
 	android_bluetooth_common.cpp \
 	android_bluetooth_BluetoothAudioGateway.cpp \
-	android_bluetooth_RfcommSocket.cpp \
+	android_bluetooth_BluetoothSocket.cpp \
 	android_bluetooth_ScoSocket.cpp \
 	android_server_BluetoothDeviceService.cpp \
 	android_server_BluetoothEventLoop.cpp \
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index c815301..21d7da9 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -143,10 +143,9 @@
 extern int register_android_text_AndroidCharacter(JNIEnv *env);
 extern int register_android_text_KeyCharacterMap(JNIEnv *env);
 extern int register_android_opengl_classes(JNIEnv *env);
-extern int register_android_bluetooth_Database(JNIEnv* env);
 extern int register_android_bluetooth_HeadsetBase(JNIEnv* env);
 extern int register_android_bluetooth_BluetoothAudioGateway(JNIEnv* env);
-extern int register_android_bluetooth_RfcommSocket(JNIEnv *env);
+extern int register_android_bluetooth_BluetoothSocket(JNIEnv *env);
 extern int register_android_bluetooth_ScoSocket(JNIEnv *env);
 extern int register_android_server_BluetoothDeviceService(JNIEnv* env);
 extern int register_android_server_BluetoothEventLoop(JNIEnv *env);
@@ -1117,10 +1116,9 @@
     REG_JNI(register_android_media_ToneGenerator),
 
     REG_JNI(register_android_opengl_classes),
-    REG_JNI(register_android_bluetooth_Database),
     REG_JNI(register_android_bluetooth_HeadsetBase),
     REG_JNI(register_android_bluetooth_BluetoothAudioGateway),
-    REG_JNI(register_android_bluetooth_RfcommSocket),
+    REG_JNI(register_android_bluetooth_BluetoothSocket),
     REG_JNI(register_android_bluetooth_ScoSocket),
     REG_JNI(register_android_server_BluetoothDeviceService),
     REG_JNI(register_android_server_BluetoothEventLoop),
diff --git a/core/jni/android_bluetooth_BluetoothSocket.cpp b/core/jni/android_bluetooth_BluetoothSocket.cpp
new file mode 100644
index 0000000..dc4c1d4
--- /dev/null
+++ b/core/jni/android_bluetooth_BluetoothSocket.cpp
@@ -0,0 +1,324 @@
+/*
+ * Copyright 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.
+ */
+
+#define LOG_TAG "BluetoothSocket.cpp"
+
+#include "android_bluetooth_common.h"
+#include "android_runtime/AndroidRuntime.h"
+#include "JNIHelp.h"
+#include "utils/Log.h"
+#include "cutils/abort_socket.h"
+
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+
+#ifdef HAVE_BLUETOOTH
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/rfcomm.h>
+#endif
+
+namespace android {
+
+static jfieldID  field_mAuth;     /* read-only */
+static jfieldID  field_mEncrypt;  /* read-only */
+static jfieldID  field_mSocketData;
+static jmethodID method_BluetoothSocket_ctor;
+static jclass    class_BluetoothSocket;
+
+static struct asocket *get_socketData(JNIEnv *env, jobject obj) {
+    struct asocket *s =
+            (struct asocket *) env->GetIntField(obj, field_mSocketData);
+    if (!s)
+        jniThrowException(env, "java/io/IOException", "null socketData");
+    return s;
+}
+
+static void initSocketFromFdNative(JNIEnv *env, jobject obj, jint fd) {
+#ifdef HAVE_BLUETOOTH
+    LOGV(__FUNCTION__);
+
+    struct asocket *s = asocket_init(fd);
+
+    if (!s) {
+        LOGV("asocket_init() failed, throwing");
+        jniThrowIOException(env, errno);
+        return;
+    }
+
+    env->SetIntField(obj, field_mSocketData, (jint)s);
+
+    return;
+#endif
+    jniThrowIOException(env, ENOSYS);
+}
+
+static void initSocketNative(JNIEnv *env, jobject obj) {
+#ifdef HAVE_BLUETOOTH
+    LOGV(__FUNCTION__);
+
+    int fd;
+    int lm = 0;
+    jboolean auth;
+    jboolean encrypt;
+
+    /*TODO: do not hardcode to rfcomm */
+    fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
+    if (fd < 0) {
+        LOGV("socket() failed, throwing");
+        jniThrowIOException(env, errno);
+        return;
+    }
+
+    auth = env->GetBooleanField(obj, field_mAuth);
+    encrypt = env->GetBooleanField(obj, field_mEncrypt);
+
+    lm |= auth ? RFCOMM_LM_AUTH : 0;
+    lm |= encrypt? RFCOMM_LM_ENCRYPT : 0;
+
+    if (lm) {
+        if (setsockopt(fd, SOL_RFCOMM, RFCOMM_LM, &lm, sizeof(lm))) {
+            LOGV("setsockopt() failed, throwing");
+            jniThrowIOException(env, errno);
+            return;
+        }
+    }
+
+    initSocketFromFdNative(env, obj, fd);
+    return;
+#endif
+    jniThrowIOException(env, ENOSYS);
+}
+
+static void connectNative(JNIEnv *env, jobject obj, jstring address,
+        jint port, jint timeout) {
+#ifdef HAVE_BLUETOOTH
+    LOGV(__FUNCTION__);
+
+    int ret;
+    struct sockaddr_rc addr;
+    const char *c_address;
+    struct asocket *s = get_socketData(env, obj);
+
+    if (!s)
+        return;
+
+    addr.rc_family = AF_BLUETOOTH;
+    addr.rc_channel = port;
+    c_address = env->GetStringUTFChars(address, NULL);
+    if (get_bdaddr((const char *)c_address, &addr.rc_bdaddr)) {
+        env->ReleaseStringUTFChars(address, c_address);
+        jniThrowIOException(env, EINVAL);
+        return;
+    }
+    env->ReleaseStringUTFChars(address, c_address);
+
+    ret = asocket_connect(s, (struct sockaddr *)&addr, sizeof(addr), timeout);
+
+    if (ret)
+        jniThrowIOException(env, errno);
+
+    return;
+#endif
+    jniThrowIOException(env, ENOSYS);
+}
+
+static void bindListenNative(JNIEnv *env, jobject obj, jint port) {
+#ifdef HAVE_BLUETOOTH
+    LOGV(__FUNCTION__);
+
+    struct sockaddr_rc addr;
+    struct asocket *s = get_socketData(env, obj);
+
+    if (!s)
+        return;
+
+    memset(&addr, 0, sizeof(struct sockaddr_rc));
+    addr.rc_family = AF_BLUETOOTH;
+    addr.rc_bdaddr = *BDADDR_ANY;
+    addr.rc_channel = port;
+
+    if (bind(s->fd, (struct sockaddr *)&addr, sizeof(addr))) {
+        jniThrowIOException(env, errno);
+        return;
+    }
+
+    if (listen(s->fd, 1)) {
+        jniThrowIOException(env, errno);
+        return;
+    }
+
+    return;
+#endif
+    jniThrowIOException(env, ENOSYS);
+}
+
+static jobject acceptNative(JNIEnv *env, jobject obj, int timeout) {
+#ifdef HAVE_BLUETOOTH
+    LOGV(__FUNCTION__);
+
+    int fd;
+    struct sockaddr_rc addr;
+    int addrlen = sizeof(addr);
+    jstring addr_jstr;
+    char addr_cstr[BTADDR_SIZE];
+    jboolean auth;
+    jboolean encrypt;
+
+    struct asocket *s = get_socketData(env, obj);
+
+    if (!s)
+        return NULL;
+
+    fd = asocket_accept(s, (struct sockaddr *)&addr, &addrlen, timeout);
+
+    if (fd < 0) {
+        jniThrowIOException(env, errno);
+        return NULL;
+    }
+
+    /* Connected - return new BluetoothSocket */
+    auth = env->GetBooleanField(obj, field_mAuth);
+    encrypt = env->GetBooleanField(obj, field_mEncrypt);
+    get_bdaddr_as_string(&addr.rc_bdaddr, addr_cstr);
+    addr_jstr = env->NewStringUTF(addr_cstr);
+    return env->NewObject(class_BluetoothSocket, method_BluetoothSocket_ctor, fd,
+            auth, encrypt, addr_jstr, -1);
+
+#endif
+    jniThrowIOException(env, ENOSYS);
+    return NULL;
+}
+
+static jint availableNative(JNIEnv *env, jobject obj) {
+#ifdef HAVE_BLUETOOTH
+    LOGV(__FUNCTION__);
+
+    int available;
+    struct asocket *s = get_socketData(env, obj);
+
+    if (!s)
+        return -1;
+
+    if (ioctl(s->fd, FIONREAD, &available) < 0) {
+        jniThrowIOException(env, errno);
+        return -1;
+    }
+
+    return available;
+
+#endif
+    jniThrowIOException(env, ENOSYS);
+    return -1;
+}
+
+static jint readNative(JNIEnv *env, jobject obj) {
+#ifdef HAVE_BLUETOOTH
+    LOGV(__FUNCTION__);
+
+    char buf;
+    struct asocket *s = get_socketData(env, obj);
+
+    if (!s)
+        return -1;
+
+    if (asocket_read(s, &buf, 1, -1) < 0) {
+        jniThrowIOException(env, errno);
+        return -1;
+    }
+
+    return (jint)buf;
+
+#endif
+    jniThrowIOException(env, ENOSYS);
+    return -1;
+}
+
+static void writeNative(JNIEnv *env, jobject obj, jint data) {
+#ifdef HAVE_BLUETOOTH
+    LOGV(__FUNCTION__);
+
+    const char buf = (char)data;
+    struct asocket *s = get_socketData(env, obj);
+
+    if (!s)
+        return;
+
+    if (asocket_write(s, &buf, 1, -1) < 0)
+        jniThrowIOException(env, errno);
+
+    return;
+#endif
+    jniThrowIOException(env, ENOSYS);
+}
+
+static void closeNative(JNIEnv *env, jobject obj) {
+#ifdef HAVE_BLUETOOTH
+    LOGV(__FUNCTION__);
+    struct asocket *s = get_socketData(env, obj);
+
+    if (!s)
+        return;
+
+    asocket_abort(s);
+    return;
+#endif
+    jniThrowIOException(env, ENOSYS);
+}
+
+static void destroyNative(JNIEnv *env, jobject obj) {
+#ifdef HAVE_BLUETOOTH
+    LOGV(__FUNCTION__);
+    struct asocket *s = get_socketData(env, obj);
+    if (!s)
+        return;
+
+    asocket_destroy(s);
+    return;
+#endif
+    jniThrowIOException(env, ENOSYS);
+}
+
+static JNINativeMethod sMethods[] = {
+    {"initSocketNative", "()V",  (void*) initSocketNative},
+    {"initSocketFromFdNative", "(I)V",  (void*) initSocketFromFdNative},
+    {"connectNative", "(Ljava/lang/String;II)V", (void *) connectNative},
+    {"bindListenNative", "(I)V", (void *) bindListenNative},
+    {"acceptNative", "(I)Landroid/bluetooth/BluetoothSocket;", (void *) acceptNative},
+    {"availableNative", "()I",    (void *) availableNative},
+    {"readNative", "()I",    (void *) readNative},
+    {"writeNative", "(I)V",    (void *) writeNative},
+    {"closeNative", "()V",    (void *) closeNative},
+    {"destroyNative", "()V",    (void *) destroyNative},
+};
+
+int register_android_bluetooth_BluetoothSocket(JNIEnv *env) {
+    jclass clazz = env->FindClass("android/bluetooth/BluetoothSocket");
+    if (clazz == NULL)
+        return -1;
+    class_BluetoothSocket = (jclass) env->NewGlobalRef(clazz);
+    field_mAuth = env->GetFieldID(clazz, "mAuth", "Z");
+    field_mEncrypt = env->GetFieldID(clazz, "mEncrypt", "Z");
+    field_mSocketData = env->GetFieldID(clazz, "mSocketData", "I");
+    method_BluetoothSocket_ctor = env->GetMethodID(clazz, "<init>", "(IZZLjava/lang/String;I)V");
+    return AndroidRuntime::registerNativeMethods(env,
+        "android/bluetooth/BluetoothSocket", sMethods, NELEM(sMethods));
+}
+
+} /* namespace android */
+
diff --git a/core/jni/android_bluetooth_Database.cpp b/core/jni/android_bluetooth_Database.cpp
deleted file mode 100644
index 73b8efd..0000000
--- a/core/jni/android_bluetooth_Database.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-#define DBUS_CLASS_NAME BLUEZ_DBUS_BASE_IFC ".Database"
-#define LOG_TAG "bluetooth_Database.cpp"
-
-#include "android_bluetooth_common.h"
-#include "android_runtime/AndroidRuntime.h"
-#include "JNIHelp.h"
-#include "jni.h"
-#include "utils/Log.h"
-
-#ifdef HAVE_BLUETOOTH
-#include <dbus/dbus.h>
-#endif
-
-namespace android {
-
-#ifdef HAVE_BLUETOOTH
-static DBusConnection* conn = NULL;   // Singleton thread-safe connection
-#endif
-
-static void classInitNative(JNIEnv* env, jclass clazz) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    conn = NULL;
-#endif
-}
-
-static void initializeNativeDataNative(JNIEnv* env, jobject object) {
-    LOGV(__FUNCTION__);
-
-#ifdef HAVE_BLUETOOTH
-    if (conn == NULL) {
-        DBusError err;
-        dbus_error_init(&err);
-        dbus_threads_init_default();
-        conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
-        if (dbus_error_is_set(&err)) {
-            LOGE("Could not get onto the system bus!");
-            dbus_error_free(&err);
-        }
-        dbus_connection_set_exit_on_disconnect(conn, FALSE);
-    }
-#endif
-}
-
-static void cleanupNativeDataNative(JNIEnv* env, jobject object) {
-    LOGV(__FUNCTION__);
-}
-
-static jint addServiceRecordNative(JNIEnv *env, jobject object,
-                                   jbyteArray record) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    if (conn != NULL) {
-        jbyte* c_record = env->GetByteArrayElements(record, NULL);
-        DBusMessage *reply = dbus_func_args(env,
-                                            conn,
-                                            BLUEZ_DBUS_BASE_PATH,
-                                            DBUS_CLASS_NAME,
-                                            "AddServiceRecord",
-                                            DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                                            &c_record,
-                                            env->GetArrayLength(record),
-                                            DBUS_TYPE_INVALID);
-        env->ReleaseByteArrayElements(record, c_record, JNI_ABORT);
-        return reply ? dbus_returns_uint32(env, reply) : -1;
-    }
-#endif
-    return -1;
-}
-
-static jint addServiceRecordFromXmlNative(JNIEnv *env, jobject object,
-                                          jstring record) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    if (conn != NULL) {
-        const char *c_record = env->GetStringUTFChars(record, NULL);
-        DBusMessage *reply = dbus_func_args(env,
-                                            conn,
-                                            BLUEZ_DBUS_BASE_PATH,
-                                            DBUS_CLASS_NAME,
-                                            "AddServiceRecordFromXML",
-                                            DBUS_TYPE_STRING, &c_record,
-                                            DBUS_TYPE_INVALID);
-        env->ReleaseStringUTFChars(record, c_record);
-        return reply ? dbus_returns_uint32(env, reply) : -1;
-    }
-#endif
-    return -1;
-}
-
-static void updateServiceRecordNative(JNIEnv *env, jobject object,
-                                      jint handle,
-                                      jbyteArray record) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    if (conn != NULL) {
-        jbyte* c_record = env->GetByteArrayElements(record, NULL);
-        DBusMessage *reply = dbus_func_args(env,
-                                            conn,
-                                            BLUEZ_DBUS_BASE_PATH,
-                                            DBUS_CLASS_NAME,
-                                            "UpdateServiceRecord",
-                                            DBUS_TYPE_UINT32, &handle,
-                                            DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                                            &c_record,
-                                            env->GetArrayLength(record),
-                                            DBUS_TYPE_INVALID);
-        env->ReleaseByteArrayElements(record, c_record, JNI_ABORT);
-    }
-#endif
-}
-
-static void updateServiceRecordFromXmlNative(JNIEnv *env, jobject object,
-                                             jint handle,
-                                             jstring record) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    if (conn != NULL) {
-        const char *c_record = env->GetStringUTFChars(record, NULL);
-        DBusMessage *reply = dbus_func_args(env,
-                                            conn,
-                                            BLUEZ_DBUS_BASE_PATH,
-                                            DBUS_CLASS_NAME,
-                                            "UpdateServiceRecordFromXML",
-                                            DBUS_TYPE_UINT32, &handle,
-                                            DBUS_TYPE_STRING, &c_record,
-                                            DBUS_TYPE_INVALID);
-        env->ReleaseStringUTFChars(record, c_record);
-    }
-#endif
-}
-
-/* private static native void removeServiceRecordNative(int handle); */
-static void removeServiceRecordNative(JNIEnv *env, jobject object,
-                                      jint handle) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    if (conn != NULL) {
-        DBusMessage *reply = dbus_func_args(env,
-                                            conn,
-                                            BLUEZ_DBUS_BASE_PATH,
-                                            DBUS_CLASS_NAME,
-                                            "RemoveServiceRecord",
-                                            DBUS_TYPE_UINT32, &handle,
-                                            DBUS_TYPE_INVALID);
-    }
-#endif
-}
-
-
-static JNINativeMethod sMethods[] = {
-     /* name, signature, funcPtr */
-    {"classInitNative", "()V", (void*)classInitNative},
-    {"initializeNativeDataNative", "()V", (void *)initializeNativeDataNative},
-    {"cleanupNativeDataNative", "()V", (void *)cleanupNativeDataNative},
-    {"addServiceRecordNative", "([B)I", (void*)addServiceRecordNative},
-    {"addServiceRecordFromXmlNative", "(Ljava/lang/String;)I", (void*)addServiceRecordFromXmlNative},
-    {"updateServiceRecordNative", "(I[B)V", (void*)updateServiceRecordNative},
-    {"updateServiceRecordFromXmlNative", "(ILjava/lang/String;)V", (void*)updateServiceRecordFromXmlNative},
-    {"removeServiceRecordNative", "(I)V", (void*)removeServiceRecordNative},
-};
-
-int register_android_bluetooth_Database(JNIEnv *env) {
-    return AndroidRuntime::registerNativeMethods(env,
-            "android/bluetooth/Database", sMethods, NELEM(sMethods));
-}
-
-} /* namespace android */
diff --git a/core/jni/android_bluetooth_RfcommSocket.cpp b/core/jni/android_bluetooth_RfcommSocket.cpp
deleted file mode 100644
index 3ed35d9..0000000
--- a/core/jni/android_bluetooth_RfcommSocket.cpp
+++ /dev/null
@@ -1,621 +0,0 @@
-/*
-** Copyright 2006, 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.
-*/
-
-#define LOG_TAG "bluetooth_RfcommSocket.cpp"
-
-#include "android_bluetooth_common.h"
-#include "android_runtime/AndroidRuntime.h"
-#include "JNIHelp.h"
-#include "jni.h"
-#include "utils/Log.h"
-#include "utils/misc.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <sys/poll.h>
-
-#ifdef HAVE_BLUETOOTH
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/rfcomm.h>
-#include <bluetooth/sco.h>
-#endif
-
-namespace android {
-
-#ifdef HAVE_BLUETOOTH
-static jfieldID field_mNativeData;
-static jfieldID field_mTimeoutRemainingMs;
-static jfieldID field_mAcceptTimeoutRemainingMs;
-static jfieldID field_mAddress;
-static jfieldID field_mPort;
-
-typedef struct {
-    jstring address;
-    const char *c_address;
-    int rfcomm_channel;
-    int last_read_err;
-    int rfcomm_sock;
-    // < 0 -- in progress, 
-    //   0 -- not connected
-    // > 0 connected
-    //     1 input is open
-    //     2 output is open
-    //     3 both input and output are open
-    int rfcomm_connected; 
-    int rfcomm_sock_flags;
-} native_data_t;
-
-static inline native_data_t * get_native_data(JNIEnv *env, jobject object) {
-    return (native_data_t *)(env->GetIntField(object, field_mNativeData));
-}
-
-static inline void init_socket_info(
-    JNIEnv *env, jobject object,
-    native_data_t *nat,
-    jstring address,
-    jint rfcomm_channel) {
-    nat->address = (jstring)env->NewGlobalRef(address);
-    nat->c_address = env->GetStringUTFChars(nat->address, NULL);
-    nat->rfcomm_channel = (int)rfcomm_channel;
-}
-
-static inline void cleanup_socket_info(JNIEnv *env, native_data_t *nat) {
-    if (nat->c_address != NULL) {
-        env->ReleaseStringUTFChars(nat->address, nat->c_address);
-        env->DeleteGlobalRef(nat->address);
-        nat->c_address = NULL;
-    }
-}
-#endif
-
-static void classInitNative(JNIEnv* env, jclass clazz) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    field_mNativeData = get_field(env, clazz, "mNativeData", "I");
-    field_mTimeoutRemainingMs = get_field(env, clazz, "mTimeoutRemainingMs", "I");
-    field_mAcceptTimeoutRemainingMs = get_field(env, clazz, "mAcceptTimeoutRemainingMs", "I");
-    field_mAddress = get_field(env, clazz, "mAddress", "Ljava/lang/String;");
-    field_mPort = get_field(env, clazz, "mPort", "I");
-#endif
-}
-
-static void initializeNativeDataNative(JNIEnv* env, jobject object) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-
-    native_data_t *nat = (native_data_t *)calloc(1, sizeof(native_data_t));
-    if (nat == NULL) {
-        LOGE("%s: out of memory!", __FUNCTION__);
-        return;
-    }
-
-    env->SetIntField(object, field_mNativeData, (jint)nat);
-    nat->rfcomm_sock = -1;
-    nat->rfcomm_connected = 0;
-#endif
-}
-
-static void cleanupNativeDataNative(JNIEnv* env, jobject object) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    native_data_t *nat = get_native_data(env, object);
-    if (nat) {
-        free(nat);
-    }
-#endif
-}
-
-static jobject createNative(JNIEnv *env, jobject obj) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    int lm;
-    native_data_t *nat = get_native_data(env, obj);
-    nat->rfcomm_sock = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
-
-    if (nat->rfcomm_sock < 0) {
-        LOGE("%s: Could not create RFCOMM socket: %s\n", __FUNCTION__,
-             strerror(errno));
-        return NULL;
-    }
-        
-    lm = RFCOMM_LM_AUTH | RFCOMM_LM_ENCRYPT;
-
-    if (lm && setsockopt(nat->rfcomm_sock, SOL_RFCOMM, RFCOMM_LM, &lm,
-                sizeof(lm)) < 0) {
-        LOGE("%s: Can't set RFCOMM link mode", __FUNCTION__);
-        close(nat->rfcomm_sock);
-        return NULL;
-    }
-
-    return jniCreateFileDescriptor(env, nat->rfcomm_sock);
-#else
-    return NULL;
-#endif
-}
-
-static void destroyNative(JNIEnv *env, jobject obj) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    native_data_t *nat = get_native_data(env, obj);
-    cleanup_socket_info(env, nat);
-    if (nat->rfcomm_sock >= 0) {
-        close(nat->rfcomm_sock);
-        nat->rfcomm_sock = -1;
-    }
-#endif
-}
-
-
-static jboolean connectNative(JNIEnv *env, jobject obj,
-                              jstring address, jint port) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    native_data_t *nat = get_native_data(env, obj);
-
-    if (nat->rfcomm_sock >= 0) {
-        if (nat->rfcomm_connected) {
-            LOGI("RFCOMM socket: %s.",
-                 (nat->rfcomm_connected > 0) ? "already connected" : "connection is in progress");
-            return JNI_TRUE;
-        }
-
-        init_socket_info(env, obj, nat, address, port);
-
-        struct sockaddr_rc addr;
-        memset(&addr, 0, sizeof(struct sockaddr_rc));
-        get_bdaddr(nat->c_address, &addr.rc_bdaddr);
-        addr.rc_channel = nat->rfcomm_channel;
-        addr.rc_family = AF_BLUETOOTH;
-        nat->rfcomm_connected = 0;
-
-        while (nat->rfcomm_connected == 0) {
-            if (connect(nat->rfcomm_sock, (struct sockaddr *)&addr,
-                    sizeof(addr)) < 0) {
-                if (errno == EINTR) continue;
-                LOGE("connect error: %s (%d)\n", strerror(errno), errno);
-                break;
-            } else {
-                nat->rfcomm_connected = 3; // input and output
-            }
-        }
-    } else {
-        LOGE("%s: socket(RFCOMM) error: socket not created", __FUNCTION__);
-    }
-
-    if (nat->rfcomm_connected > 0) {
-        env->SetIntField(obj, field_mPort, port);
-        return JNI_TRUE;
-    }
-#endif
-    return JNI_FALSE;
-}
-
-static jboolean connectAsyncNative(JNIEnv *env, jobject obj,
-                                   jstring address, jint port) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    native_data_t *nat = get_native_data(env, obj);
-
-    if (nat->rfcomm_sock < 0) {
-        LOGE("%s: socket(RFCOMM) error: socket not created", __FUNCTION__);
-        return JNI_FALSE;
-    }
-
-    if (nat->rfcomm_connected) {
-        LOGI("RFCOMM socket: %s.",
-             (nat->rfcomm_connected > 0) ?
-             "already connected" : "connection is in progress");
-        return JNI_TRUE;
-    }
-
-    init_socket_info(env, obj, nat, address, port);
-
-    struct sockaddr_rc addr;
-    memset(&addr, 0, sizeof(struct sockaddr_rc));
-    get_bdaddr(nat->c_address, &addr.rc_bdaddr);
-    addr.rc_channel = nat->rfcomm_channel;
-    addr.rc_family = AF_BLUETOOTH;
-
-    nat->rfcomm_sock_flags = fcntl(nat->rfcomm_sock, F_GETFL, 0);
-    if (fcntl(nat->rfcomm_sock,
-              F_SETFL, nat->rfcomm_sock_flags | O_NONBLOCK) >= 0) {
-        int rc;
-        nat->rfcomm_connected = 0;
-        errno = 0;
-        rc = connect(nat->rfcomm_sock,
-                     (struct sockaddr *)&addr,
-                     sizeof(addr));
-
-        if (rc >= 0) {
-            nat->rfcomm_connected = 3;
-            LOGI("RFCOMM async connect immediately successful");
-            env->SetIntField(obj, field_mPort, port);
-            return JNI_TRUE;
-        }
-        else if (rc < 0) {
-            if (errno == EINPROGRESS || errno == EAGAIN)
-                {
-                    LOGI("RFCOMM async connect is in progress (%s)",
-                         strerror(errno));
-                    nat->rfcomm_connected = -1;
-                    env->SetIntField(obj, field_mPort, port);
-                    return JNI_TRUE;
-                }
-            else
-                {
-                    LOGE("RFCOMM async connect error (%d): %s (%d)",
-                         nat->rfcomm_sock, strerror(errno), errno);
-                    return JNI_FALSE;
-                }
-        }
-    } // fcntl(nat->rfcomm_sock ...)
-#endif
-    return JNI_FALSE;
-}
-
-static jboolean interruptAsyncConnectNative(JNIEnv *env, jobject obj) {
-    //WRITEME
-    return JNI_TRUE;
-}
-
-static jint waitForAsyncConnectNative(JNIEnv *env, jobject obj,
-                                      jint timeout_ms) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    struct sockaddr_rc addr;
-    native_data_t *nat = get_native_data(env, obj);
-
-    env->SetIntField(obj, field_mTimeoutRemainingMs, timeout_ms);
-
-    if (nat->rfcomm_sock < 0) {
-        LOGE("%s: socket(RFCOMM) error: socket not created", __FUNCTION__);
-        return -1;
-    }
-
-    if (nat->rfcomm_connected > 0) {
-        LOGI("%s: RFCOMM is already connected!", __FUNCTION__);
-        return 1;
-    }
-
-    /* Do an asynchronous select() */
-    int n;
-    fd_set rset, wset;
-    struct timeval to;
-
-    FD_ZERO(&rset);
-    FD_ZERO(&wset);
-    FD_SET(nat->rfcomm_sock, &rset);
-    FD_SET(nat->rfcomm_sock, &wset);
-    if (timeout_ms >= 0) {
-        to.tv_sec = timeout_ms / 1000;
-        to.tv_usec = 1000 * (timeout_ms % 1000);
-    }
-    n = select(nat->rfcomm_sock + 1,
-               &rset,
-               &wset,
-               NULL,
-               (timeout_ms < 0 ? NULL : &to));
-
-    if (timeout_ms > 0) {
-        jint remaining = to.tv_sec*1000 + to.tv_usec/1000;
-        LOGI("Remaining time %ldms", (long)remaining);
-        env->SetIntField(obj, field_mTimeoutRemainingMs,
-                         remaining);
-    }
-
-    if (n <= 0) {
-        if (n < 0)  {
-            LOGE("select() on RFCOMM socket: %s (%d)",
-                 strerror(errno),
-                 errno);
-            return -1;
-        }
-        return 0;
-    }
-    /* n must be equal to 1 and either rset or wset must have the
-       file descriptor set. */
-    LOGI("select() returned %d.", n);
-    if (FD_ISSET(nat->rfcomm_sock, &rset) ||
-        FD_ISSET(nat->rfcomm_sock, &wset)) {
-        /* A trial async read() will tell us if everything is OK. */
-        char ch;
-        errno = 0;
-        int nr = read(nat->rfcomm_sock, &ch, 1);
-        /* It should be that nr != 1 because we just opened a socket
-           and we haven't sent anything over it for the other side to
-           respond... but one can't be paranoid enough.
-        */
-        if (nr >= 0 || errno != EAGAIN) {
-            LOGE("RFCOMM async connect() error: %s (%d), nr = %d\n",
-                 strerror(errno),
-                 errno,
-                 nr);
-            /* Clear the rfcomm_connected flag to cause this function
-               to re-create the socket and re-attempt the connect()
-               the next time it is called.
-            */
-            nat->rfcomm_connected = 0;
-            /* Restore the blocking properties of the socket. */
-            fcntl(nat->rfcomm_sock, F_SETFL, nat->rfcomm_sock_flags);
-            return -1;
-        }
-        /* Restore the blocking properties of the socket. */
-        fcntl(nat->rfcomm_sock, F_SETFL, nat->rfcomm_sock_flags);
-        LOGI("Successful RFCOMM socket connect.");
-        nat->rfcomm_connected = 3; // input and output
-        return 1;
-    }
-#endif
-    return -1;
-}
-
-static jboolean shutdownNative(JNIEnv *env, jobject obj,
-                jboolean shutdownInput) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    /* NOTE: If you change the bcode to modify nat, make sure you 
-       add synchronize(this) to the method calling this native
-       method. 
-    */
-    native_data_t *nat = get_native_data(env, obj);
-    if (nat->rfcomm_sock < 0) {
-        LOGE("socket(RFCOMM) error: socket not created");
-        return JNI_FALSE;
-    }
-    int rc = shutdown(nat->rfcomm_sock, 
-            shutdownInput ? SHUT_RD : SHUT_WR);
-    if (!rc) {
-        nat->rfcomm_connected &= 
-            shutdownInput ? ~1 : ~2;
-        return JNI_TRUE;
-    }
-#endif
-    return JNI_FALSE;
-}
-
-static jint isConnectedNative(JNIEnv *env, jobject obj) {
-    LOGI(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    const native_data_t *nat = get_native_data(env, obj);
-    return nat->rfcomm_connected;
-#endif
-    return 0;
-}
-
-//@@@@@@@@@ bind to device???
-static jboolean bindNative(JNIEnv *env, jobject obj, jstring device,
-                           jint port) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-
-    /* NOTE: If you change the code to modify nat, make sure you
-       add synchronize(this) to the method calling this native
-       method.
-    */
-    const native_data_t *nat = get_native_data(env, obj);
-    if (nat->rfcomm_sock < 0) {
-        LOGE("socket(RFCOMM) error: socket not created");
-        return JNI_FALSE;
-    }
-
-    struct sockaddr_rc laddr;
-    int lm;
-
-    lm = 0;
-/*
-    lm |= RFCOMM_LM_MASTER;
-    lm |= RFCOMM_LM_AUTH;
-    lm |= RFCOMM_LM_ENCRYPT;
-    lm |= RFCOMM_LM_SECURE;
-*/
-
-    if (lm && setsockopt(nat->rfcomm_sock, SOL_RFCOMM, RFCOMM_LM, &lm, sizeof(lm)) < 0) {
-        LOGE("Can't set RFCOMM link mode");
-        return JNI_FALSE;
-    }
-
-    laddr.rc_family = AF_BLUETOOTH;
-    bacpy(&laddr.rc_bdaddr, BDADDR_ANY);
-    laddr.rc_channel = port;
-
-    if (bind(nat->rfcomm_sock, (struct sockaddr *)&laddr, sizeof(laddr)) < 0) {
-        LOGE("Can't bind RFCOMM socket");
-        return JNI_FALSE;
-    }
-
-    env->SetIntField(obj, field_mPort, port);
-
-    return JNI_TRUE;
-#endif
-    return JNI_FALSE;
-}
-
-static jboolean listenNative(JNIEnv *env, jobject obj, jint backlog) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    /* NOTE: If you change the code to modify nat, make sure you
-       add synchronize(this) to the method calling this native
-       method.
-    */
-    const native_data_t *nat = get_native_data(env, obj);
-    if (nat->rfcomm_sock < 0) {
-        LOGE("socket(RFCOMM) error: socket not created");
-        return JNI_FALSE;
-    }
-    return listen(nat->rfcomm_sock, backlog) < 0 ? JNI_FALSE : JNI_TRUE;
-#else
-    return JNI_FALSE;
-#endif
-}
-
-static int set_nb(int sk, bool nb) {
-    int flags = fcntl(sk, F_GETFL);
-    if (flags < 0) {
-        LOGE("Can't get socket flags with fcntl(): %s (%d)",
-             strerror(errno), errno);
-        close(sk);
-        return -1;
-    }
-    flags &= ~O_NONBLOCK;
-    if (nb) flags |= O_NONBLOCK;
-    int status = fcntl(sk, F_SETFL, flags);
-    if (status < 0) {
-        LOGE("Can't set socket to nonblocking mode with fcntl(): %s (%d)",
-             strerror(errno), errno);
-        close(sk);
-        return -1;
-    }
-    return 0;
-}
-
-// Note: the code should check at a higher level to see whether
-// listen() has been called.
-#ifdef HAVE_BLUETOOTH
-static int do_accept(JNIEnv* env, jobject object, int sock,
-                     jobject newsock,
-                     jfieldID out_address,
-                     bool must_succeed) {
-
-    if (must_succeed && set_nb(sock, true) < 0)
-        return -1;
-
-    struct sockaddr_rc raddr;
-    int alen = sizeof(raddr);
-    int nsk = accept(sock, (struct sockaddr *) &raddr, &alen);
-    if (nsk < 0) {
-        LOGE("Error on accept from socket fd %d: %s (%d).",
-             sock,
-             strerror(errno),
-             errno);
-        if (must_succeed) set_nb(sock, false);
-        return -1;
-    }
-
-    char addr[BTADDR_SIZE];
-    get_bdaddr_as_string(&raddr.rc_bdaddr, addr);
-    env->SetObjectField(newsock, out_address, env->NewStringUTF(addr));
-
-    LOGI("Successful accept() on AG socket %d: new socket %d, address %s, RFCOMM channel %d",
-         sock,
-         nsk,
-         addr,
-         raddr.rc_channel);
-    if (must_succeed) set_nb(sock, false);
-    return nsk;
-}
-#endif /*HAVE_BLUETOOTH*/
-
-static jobject acceptNative(JNIEnv *env, jobject obj,
-                            jobject newsock, jint timeoutMs) {
-    LOGV(__FUNCTION__);
-#ifdef HAVE_BLUETOOTH
-    native_data_t *nat = get_native_data(env, obj);
-    if (nat->rfcomm_sock < 0) {
-        LOGE("socket(RFCOMM) error: socket not created");
-        return JNI_FALSE;
-    }
-
-    if (newsock == NULL) {
-        LOGE("%s: newsock = NULL\n", __FUNCTION__);
-        return JNI_FALSE;
-    }
-
-    int nsk = -1;
-    if (timeoutMs < 0) {
-        /* block until accept() succeeds */
-        nsk = do_accept(env, obj, nat->rfcomm_sock,
-                        newsock, field_mAddress, false);
-        if (nsk < 0) {
-            return NULL;
-        }
-    }
-    else {
-        /* wait with a timeout */
-
-        struct pollfd fds;
-        fds.fd = nat->rfcomm_sock;
-        fds.events = POLLIN | POLLPRI | POLLOUT | POLLERR;
-
-        env->SetIntField(obj, field_mAcceptTimeoutRemainingMs, 0);
-        int n = poll(&fds, 1, timeoutMs);
-        if (n <= 0) {
-            if (n < 0)  {
-                LOGE("listening poll() on RFCOMM socket: %s (%d)",
-                     strerror(errno),
-                     errno);
-                env->SetIntField(obj, field_mAcceptTimeoutRemainingMs, timeoutMs);
-            }
-            else {
-                LOGI("listening poll() on RFCOMM socket timed out");
-            }
-            return NULL;
-        }
-
-        LOGI("listening poll() on RFCOMM socket returned %d", n);
-        if (fds.fd == nat->rfcomm_sock) {
-            if (fds.revents & (POLLIN | POLLPRI | POLLOUT)) {
-                LOGI("Accepting connection.\n");
-                nsk = do_accept(env, obj, nat->rfcomm_sock,
-                                newsock, field_mAddress, true);
-                if (nsk < 0) {
-                    return NULL;
-                }
-            }
-        }
-    }
-
-    LOGI("Connection accepted, new socket fd = %d.", nsk);
-    native_data_t *newnat = get_native_data(env, newsock);
-    newnat->rfcomm_sock = nsk;
-    newnat->rfcomm_connected = 3;
-    return jniCreateFileDescriptor(env, nsk);
-#else
-    return NULL;
-#endif
-}
-
-static JNINativeMethod sMethods[] = {
-     /* name, signature, funcPtr */
-    {"classInitNative", "()V", (void*)classInitNative},
-    {"initializeNativeDataNative", "()V", (void *)initializeNativeDataNative},
-    {"cleanupNativeDataNative", "()V", (void *)cleanupNativeDataNative},
-
-    {"createNative", "()Ljava/io/FileDescriptor;", (void *)createNative},
-    {"destroyNative", "()V", (void *)destroyNative},
-    {"connectNative", "(Ljava/lang/String;I)Z", (void *)connectNative},
-    {"connectAsyncNative", "(Ljava/lang/String;I)Z", (void *)connectAsyncNative},
-    {"interruptAsyncConnectNative", "()Z", (void *)interruptAsyncConnectNative},
-    {"waitForAsyncConnectNative", "(I)I", (void *)waitForAsyncConnectNative},
-    {"shutdownNative", "(Z)Z", (void *)shutdownNative},
-    {"isConnectedNative", "()I", (void *)isConnectedNative},
-
-    {"bindNative", "(Ljava/lang/String;I)Z", (void*)bindNative},
-    {"listenNative", "(I)Z", (void*)listenNative},
-    {"acceptNative", "(Landroid/bluetooth/RfcommSocket;I)Ljava/io/FileDescriptor;", (void*)acceptNative},
-};
-
-int register_android_bluetooth_RfcommSocket(JNIEnv *env) {
-    return AndroidRuntime::registerNativeMethods(env,
-        "android/bluetooth/RfcommSocket", sMethods, NELEM(sMethods));
-}
-
-} /* namespace android */
diff --git a/core/jni/android_bluetooth_common.cpp b/core/jni/android_bluetooth_common.cpp
index 0b8a604..ee672f7 100644
--- a/core/jni/android_bluetooth_common.cpp
+++ b/core/jni/android_bluetooth_common.cpp
@@ -390,17 +390,18 @@
     return byteArray;
 }
 
-void get_bdaddr(const char *str, bdaddr_t *ba) {
+int get_bdaddr(const char *str, bdaddr_t *ba) {
     char *d = ((char *)ba) + 5, *endp;
     int i;
     for(i = 0; i < 6; i++) {
         *d-- = strtol(str, &endp, 16);
         if (*endp != ':' && i != 5) {
             memset(ba, 0, sizeof(bdaddr_t));
-            return;
+            return -1;
         }
         str = endp + 1;
     }
+    return 0;
 }
 
 void get_bdaddr_as_string(const bdaddr_t *ba, char *str) {
diff --git a/core/jni/android_bluetooth_common.h b/core/jni/android_bluetooth_common.h
index 69092dd..e5b8813 100644
--- a/core/jni/android_bluetooth_common.h
+++ b/core/jni/android_bluetooth_common.h
@@ -144,7 +144,7 @@
 jobjectArray dbus_returns_array_of_strings(JNIEnv *env, DBusMessage *reply);
 jbyteArray dbus_returns_array_of_bytes(JNIEnv *env, DBusMessage *reply);
 
-void get_bdaddr(const char *str, bdaddr_t *ba);
+int get_bdaddr(const char *str, bdaddr_t *ba);
 void get_bdaddr_as_string(const bdaddr_t *ba, char *str);
 
 bool debug_no_encrypt();
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index fd78f83..5870c39 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -598,7 +598,7 @@
         <flag name="time" value="0x00000024" />
     </attr>
 
-    <!-- Additional features you can enable in an IME associated with an editor,
+    <!-- Additional features you can enable in an IME associated with an editor
          to improve the integration with your application.  The constants
          here correspond to those defined by
          {@link android.view.inputmethod.EditorInfo#imeOptions}. -->
@@ -682,7 +682,7 @@
     <attr name="y" format="dimension" />
 
     <!-- Specifies how to place the content of an object, both
-         on the x and y axis, within the object itself. -->
+         on the x- and y-axis, within the object itself. -->
     <attr name="gravity">
         <!-- Push object to the top of its container, not changing its size. -->
         <flag name="top" value="0x30" />
@@ -738,7 +738,7 @@
     <attr name="entries" format="reference" />
 
     <!-- Standard gravity constant that a child can supply to its parent.
-         Defines how to place the view, both its x and y axis, within its parent view group. -->
+         Defines how to place the view, both its x- and y-axis, within its parent view group. -->
     <attr name="layout_gravity">
         <!-- Push object to the top of its container, not changing its size. -->
         <flag name="top" value="0x30" />
@@ -1817,7 +1817,7 @@
         <attr name="minEms" format="integer" min="0" />
         <!-- Makes the TextView be at least this many pixels wide -->
         <attr name="minWidth" />
-        <!-- Specifies how to align the text by the view's x and/or y axis
+        <!-- Specifies how to align the text by the view's x- and/or y-axis
              when the text is smaller than the view. -->
         <attr name="gravity" />
         <!-- Whether the text is allowed to be wider than the view (and
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index aaaebbb..3c68c34 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -800,7 +800,7 @@
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_readFrameBuffer">read frame buffer</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permdesc_readFrameBuffer">Allows application to use
+    <string name="permdesc_readFrameBuffer">Allows application to 
         read the content of the frame buffer.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
diff --git a/docs/html/guide/appendix/faq/commontasks.jd b/docs/html/guide/appendix/faq/commontasks.jd
index 0f89e75..259b5d1 100644
--- a/docs/html/guide/appendix/faq/commontasks.jd
+++ b/docs/html/guide/appendix/faq/commontasks.jd
@@ -427,7 +427,7 @@
         <td>Activity</td>
         <td>By setting the theme of an activity to
             {@link android.R.style#Theme_Dialog 
-            android:theme=&quot;android:style/Theme.Dialog&quot;}, 
+            android:theme=&quot;&#064;android:style/Theme.Dialog&quot;}, 
             your activity will take on
             the appearance of a normal dialog, floating on top of whatever was
             underneath it.  You usually set the theme through the
diff --git a/docs/html/guide/developing/tools/adb.jd b/docs/html/guide/developing/tools/adb.jd
index b111047..e8c726f 100644
--- a/docs/html/guide/developing/tools/adb.jd
+++ b/docs/html/guide/developing/tools/adb.jd
@@ -313,7 +313,7 @@
 <li><code>&lt;tty&gt;</code> &mdash; the tty for PPP stream. For example <code>dev:/dev/omap_csmi_ttyl</code>. </li>
 <li><code>[parm]... </code> &mdash zero or more PPP/PPPD options, such as <code>defaultroute</code>, <code>local</code>, <code>notty</code>, etc.</li></ul>
 
-<p>Note that you should not automatically start a PDP connection. </p></td>
+<p>Note that you should not automatically start a PPP connection. </p></td>
 <td></td>
 </tr>
 
diff --git a/docs/html/guide/topics/fundamentals.jd b/docs/html/guide/topics/fundamentals.jd
index 71705d3..640e44b 100644
--- a/docs/html/guide/topics/fundamentals.jd
+++ b/docs/html/guide/topics/fundamentals.jd
@@ -72,8 +72,8 @@
 runs in isolation from the code of all other applications.</li>
 
 <li>By default, each application is assigned a unique Linux user ID.  
-Permissions are set so that the application's files are visible only 
-that user, only to the application itself &mdash; although there are ways 
+Permissions are set so that the application's files are visible only to
+that user and only to the application itself &mdash; although there are ways
 to export them to other applications as well.</li>
 </ul>
 
diff --git a/docs/html/guide/topics/manifest/manifest-element.jd b/docs/html/guide/topics/manifest/manifest-element.jd
index a9d1090..48e598a 100644
--- a/docs/html/guide/topics/manifest/manifest-element.jd
+++ b/docs/html/guide/topics/manifest/manifest-element.jd
@@ -44,8 +44,11 @@
 
 <dt><a name="package"></a>{@code package}</dt>
 <dd>A full Java package name for the application.  The name should 
-be unique.  For example, applications published by Google could have 
-names in the form <code>com.google.app.<i>application_name</i></code>.
+be unique.  The name may contain uppercase or lowercase letters ('A'
+through 'Z'), numbers, and underscores ('_').  However, individual
+package name parts may only start with letters.  For example, applications
+published by Google could have names in the form
+<code>com.google.app.<i>application_name</i></code>.
 
 <p>
 The package name serves as a unique identifier for the application.  
diff --git a/docs/html/guide/tutorials/views/hello-mapview.jd b/docs/html/guide/tutorials/views/hello-mapview.jd
index 531300f..7a21485 100644
--- a/docs/html/guide/tutorials/views/hello-mapview.jd
+++ b/docs/html/guide/tutorials/views/hello-mapview.jd
@@ -93,28 +93,6 @@
 }
 </pre>
 <p>You can actually run this now, but all it does is allow you to pan around the map.</p>
-<p>Android provides a handy {@link android.widget.ZoomControls} widget for zooming in and out of a View. 
-MapView can automatically hook one for us by requesting it with the <code>getZoomControls()</code>
-method. Let's do this.</p>
-
-<li>Go back to the layout file. We need a new ViewGroup element, in which we'll 
-   place the ZoomControls. Just below the MapView element (but inside the RelativeLayout), add this element:
-<pre>
-&lt;LinearLayout
-    android:id="@+id/zoomview"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:layout_alignBottom="@id/mapview"
-    android:layout_centerHorizontal="true"
-/></pre>
-
-      <p>It doesn't really matter what kind of ViewGroup we use, because we just want a 
-      container that we can position within our root RelativeLayout.</p>
-
-      <p>The last two attributes are available only to an element that's a child of a 
-      RelativeLayout. <code>layout_alignBottom</code> aligns the bottom of this element to the bottom of 
-      the element identified with a resource tag (which must be a sibling to this element). 
-      <code>layout_centerHorizontal</code> centers this on the horizontal plane.</p></li>
 
    <li>Now go back to the HelloMapView class. We'll now retrieve the ZoomControls object from 
    the MapView and add it to our new layout element. First, at the top of the HelloMapView, 
@@ -122,24 +100,18 @@
 <pre>
 LinearLayout linearLayout;
 MapView mapView;
-ZoomControls mZoom;</pre></li>
+</pre>
 
    <li>Then initialize each of these in <code>onCreate()</code>. We'll capture the LinearLayout and 
    MapView through their layout resources. Then get the ZoomControls from the MapView::
 <pre>
-linearLayout = (LinearLayout) findViewById(R.id.zoomview);
 mapView = (MapView) findViewById(R.id.mapview);
-mZoom = (ZoomControls) mapView.getZoomControls();</pre>
+mapView.setBuiltInZoomControls(true);
+</pre>
 
-      <p>By using the ZoomControls object provided by MapView, we don't have to do any of the work
-      required to actually perform the zoom operations. The ZoomControls widget that MapView 
-      returns for us is already hooked into the MapView and works as soon as we add it to the 
-      layout. The controls will appear whenever the user touches the map, then dissapear after 
-      a few moments of inactivity.</p></li>
-
-   <li>Now just plug our ZoomControls into the LinearLayout we added:
-
-      <pre>linearLayout.addView(mZoom);</pre></li>
+      <p>By using the built-in zoom control provided by MapView, we don't have to do any of the work
+      required to actually perform the zoom operations. The controls will appear whenever the user
+      touches the map, then disappear after a few moments of inactivity.</p></li>
 
    <li>Run it.</li>
 </ol>
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 0a0e4eb..193f399 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -102,7 +102,7 @@
     private int[] mStateSet = StateSet.WILD_CARD;
     private int mLevel = 0;
     private int mChangingConfigurations = 0;
-    private Rect mBounds = ZERO_BOUNDS_RECT;
+    private Rect mBounds = ZERO_BOUNDS_RECT;  // lazily becomes a new Rect()
     /*package*/ Callback mCallback = null;
     private boolean mVisible = true;
 
diff --git a/include/media/PVPlayer.h b/include/media/PVPlayer.h
index 8122df6..de7a041 100644
--- a/include/media/PVPlayer.h
+++ b/include/media/PVPlayer.h
@@ -62,6 +62,7 @@
     static void         run_set_video_surface(status_t s, void *cookie, bool cancelled);
     static void         run_set_audio_output(status_t s, void *cookie, bool cancelled);
     static void         run_prepare(status_t s, void *cookie, bool cancelled);
+    static void         check_for_live_streaming(status_t s, void *cookie, bool cancelled);
 
     PlayerDriver*               mPlayerDriver;
     char *                      mDataSourcePath;
diff --git a/include/private/opengles/gl_context.h b/include/private/opengles/gl_context.h
index a85f275..e32e332 100644
--- a/include/private/opengles/gl_context.h
+++ b/include/private/opengles/gl_context.h
@@ -285,6 +285,7 @@
     vec4_t      normalizedObjPosition;
     vec4_t      spotDir;
     vec4_t      normalizedSpotDir;
+    vec4_t      objViewer;
     GLfixed     spotExp;
     GLfixed     spotCutoff;
     GLfixed     spotCutoffCosine;
diff --git a/include/tts/TtsEngine.h b/include/tts/TtsEngine.h
index 21cb73b..ed084ca 100644
--- a/include/tts/TtsEngine.h
+++ b/include/tts/TtsEngine.h
@@ -80,6 +80,8 @@
 class TtsEngine
 {
 public:
+    virtual ~TtsEngine() {}
+
     // Initialize the TTS engine and returns whether initialization succeeded.
     // @param synthDoneCBPtr synthesis callback function pointer
     // @return TTS_SUCCESS, or TTS_FAILURE
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index da7cc8a..b8e5bd0 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -654,6 +654,7 @@
     }
 
     status_t ret = NO_ERROR;
+    
     if (stream == AudioSystem::VOICE_CALL ||
         stream == AudioSystem::BLUETOOTH_SCO) {
         float hwValue;
@@ -670,7 +671,13 @@
         mHardwareStatus = AUDIO_SET_VOICE_VOLUME;
         ret = mAudioHardware->setVoiceVolume(hwValue);
         mHardwareStatus = AUDIO_HW_IDLE;
+        
     }
+    
+    mHardwareMixerThread->setStreamVolume(stream, value);
+#ifdef WITH_A2DP
+    mA2dpMixerThread->setStreamVolume(stream, value);
+#endif
 
     mHardwareMixerThread->setStreamVolume(stream, value);
 #ifdef WITH_A2DP
diff --git a/libs/surfaceflinger/LayerScreenshot.cpp b/libs/surfaceflinger/LayerScreenshot.cpp
new file mode 100644
index 0000000..fb7b585
--- /dev/null
+++ b/libs/surfaceflinger/LayerScreenshot.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2007 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.
+ */
+
+#define LOG_TAG "SurfaceFlinger"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/Errors.h>
+#include <utils/Log.h>
+
+#include <core/SkBitmap.h>
+
+#include <ui/EGLDisplaySurface.h>
+
+#include "LayerBase.h"
+#include "LayerScreenshot.h"
+#include "SurfaceFlinger.h"
+#include "DisplayHardware/DisplayHardware.h"
+
+namespace android {
+// ---------------------------------------------------------------------------
+
+const uint32_t LayerScreenshot::typeInfo = LayerBase::typeInfo | 0x20;
+const char* const LayerScreenshot::typeID = "LayerScreenshot";
+
+// ---------------------------------------------------------------------------
+
+LayerScreenshot::LayerScreenshot(SurfaceFlinger* flinger, DisplayID display)
+    : LayerBase(flinger, display), mReply(0)
+{
+}
+
+LayerScreenshot::~LayerScreenshot()
+{
+}
+
+void LayerScreenshot::onDraw(const Region& clip) const
+{
+    const DisplayHardware& hw(graphicPlane(0).displayHardware());
+    copybit_image_t dst;
+    hw.getDisplaySurface(&dst);
+    if (dst.base != 0) {
+        uint8_t const* src = (uint8_t const*)(intptr_t(dst.base) + dst.offset); 
+        const int fbWidth = dst.w;
+        const int fbHeight = dst.h;
+        const int fbFormat = dst.format;
+
+        int x = mTransformedBounds.left;
+        int y = mTransformedBounds.top;
+        int w = mTransformedBounds.width();
+        int h = mTransformedBounds.height();
+        Parcel* const reply = mReply;
+        if (reply) {
+            const size_t Bpp = bytesPerPixel(fbFormat);
+            const size_t size = w * h * Bpp;
+            int32_t cfg = SkBitmap::kNo_Config;
+            switch (fbFormat) {
+                case PIXEL_FORMAT_RGBA_4444: cfg = SkBitmap::kARGB_4444_Config; break;
+                case PIXEL_FORMAT_RGBA_8888: cfg = SkBitmap::kARGB_8888_Config; break;
+                case PIXEL_FORMAT_RGB_565:   cfg = SkBitmap::kRGB_565_Config; break;
+                case PIXEL_FORMAT_A_8:       cfg = SkBitmap::kA8_Config; break;
+            }
+            reply->writeInt32(0);
+            reply->writeInt32(cfg);
+            reply->writeInt32(w);
+            reply->writeInt32(h);
+            reply->writeInt32(w * Bpp);
+            void* data = reply->writeInplace(size);
+            if (data) {
+                uint8_t* d = (uint8_t*)data;
+                uint8_t const* s = src + (x + y*fbWidth) * Bpp;
+                if (w == fbWidth) {
+                    memcpy(d, s, w*h*Bpp);   
+                } else {
+                    for (int y=0 ; y<h ; y++) {
+                        memcpy(d, s, w*Bpp);
+                        d += w*Bpp;
+                        s += fbWidth*Bpp;
+                    }
+                }
+            }
+        }
+    }
+    mCV.broadcast();
+}
+
+void LayerScreenshot::takeScreenshot(Mutex& lock, Parcel* reply)
+{
+    mReply = reply;
+    mCV.wait(lock);
+}
+
+// ---------------------------------------------------------------------------
+
+}; // namespace android
diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp
index 97dfecc..7a277fe 100644
--- a/libs/surfaceflinger/SurfaceFlinger.cpp
+++ b/libs/surfaceflinger/SurfaceFlinger.cpp
@@ -23,6 +23,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <math.h>
+#include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index 86ea66f..ca16f19 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -68,7 +68,7 @@
      * satellites. Depending on conditions, this provider may take a while to return
      * a location fix.
      *
-     * Requires the permission android.permissions.ACCESS_FINE_LOCATION.
+     * Requires the permission android.permission.ACCESS_FINE_LOCATION.
      *
      * <p> The extras Bundle for the GPS location provider can contain the
      * following key/value pairs:
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 3b46d69..fe768be 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -644,7 +644,8 @@
     }
 
     /**
-     * Sets the data source (FileDescriptor) to use.  It is the caller's responsibility
+     * Sets the data source (FileDescriptor) to use.  The FileDescriptor must be
+     * seekable (N.B. a LocalSocket is not seekable). It is the caller's responsibility
      * to close the file descriptor. It is safe to do so as soon as this call returns.
      *
      * @param fd the FileDescriptor for the file you want to play
diff --git a/media/jni/Android.mk b/media/jni/Android.mk
index 8ee0cbd..3b05984 100644
--- a/media/jni/Android.mk
+++ b/media/jni/Android.mk
@@ -1,7 +1,8 @@
-ifneq ($(BUILD_WITHOUT_PV),true)
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
+ifneq ($(BUILD_WITHOUT_PV),true)
+
 LOCAL_SRC_FILES:= \
     android_media_MediaPlayer.cpp \
     android_media_MediaRecorder.cpp \
@@ -38,6 +39,7 @@
 
 include $(BUILD_SHARED_LIBRARY)
 
+endif
+
 # build libsoundpool.so
 include $(LOCAL_PATH)/soundpool/Android.mk
-endif
diff --git a/media/libmediaplayerservice/Android.mk b/media/libmediaplayerservice/Android.mk
index f7f2490..99f222b 100644
--- a/media/libmediaplayerservice/Android.mk
+++ b/media/libmediaplayerservice/Android.mk
@@ -27,9 +27,19 @@
     libmedia \
     libandroid_runtime
 
+ifneq ($(BUILD_WITHOUT_PV),true)
+LOCAL_SHARED_LIBRARIES += \
+	libopencore_player \
+	libopencore_author
+endif
+
 LOCAL_C_INCLUDES := external/tremor/Tremor \
     $(call include-path-for, graphics corecg)
 
+ifeq ($(BUILD_WITHOUT_PV),true)
+LOCAL_CFLAGS := -DNO_OPENCORE
+endif
+
 LOCAL_MODULE:= libmediaplayerservice
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index 31eecac..8ef0dc6 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -105,7 +105,11 @@
 
 sp<IMediaRecorder> MediaPlayerService::createMediaRecorder(pid_t pid)
 {
+#ifndef NO_OPENCORE
     sp<MediaRecorderClient> recorder = new MediaRecorderClient(pid);
+#else
+    sp<MediaRecorderClient> recorder = NULL;
+#endif
     LOGV("Create new media recorder client from pid %d", pid);
     return recorder;
 }
@@ -532,10 +536,12 @@
 {
     sp<MediaPlayerBase> p;
     switch (playerType) {
+#ifndef NO_OPENCORE
         case PV_PLAYER:
             LOGV(" create PVPlayer");
             p = new PVPlayer();
             break;
+#endif
         case SONIVOX_PLAYER:
             LOGV(" create MidiFile");
             p = new MidiFile();
diff --git a/media/libmediaplayerservice/MetadataRetrieverClient.cpp b/media/libmediaplayerservice/MetadataRetrieverClient.cpp
index a320bd5..6cb4a34 100644
--- a/media/libmediaplayerservice/MetadataRetrieverClient.cpp
+++ b/media/libmediaplayerservice/MetadataRetrieverClient.cpp
@@ -49,7 +49,11 @@
     mThumbnail = NULL;
     mAlbumArt = NULL;
 
+#ifndef NO_OPENCORE
     mRetriever = new PVMetadataRetriever();
+#else
+    mRetriever = NULL;
+#endif
     if (mRetriever == NULL) {
         LOGE("failed to initialize the retriever");
     }
diff --git a/opengl/java/android/opengl/GLLogWrapper.java b/opengl/java/android/opengl/GLLogWrapper.java
index 4119bf8..f332448 100644
--- a/opengl/java/android/opengl/GLLogWrapper.java
+++ b/opengl/java/android/opengl/GLLogWrapper.java
@@ -1517,7 +1517,7 @@
         arg("count", count);
         startLogIndices();
         for (int i = 0; i < count; i++) {
-            doElement(mStringBuilder, i, first + count);
+            doElement(mStringBuilder, i, first + i);
         }
         endLogIndices();
         end();
diff --git a/opengl/libagl/light.cpp b/opengl/libagl/light.cpp
index 8ae32cc0f..f211bca 100644
--- a/opengl/libagl/light.cpp
+++ b/opengl/libagl/light.cpp
@@ -216,6 +216,8 @@
 static inline void validate_light_mvi(ogles_context_t* c)
 {
     uint32_t en = c->lighting.enabledLights;
+    // Vector from object to viewer, in eye coordinates
+    const vec4_t eyeViewer = { 0, 0, 0x1000, 0 };
     while (en) {
         const int i = 31 - gglClz(en);
         en &= ~(1<<i);
@@ -223,6 +225,9 @@
         c->transforms.mvui.point4(&c->transforms.mvui,
                 &l.objPosition, &l.position);
         vnorm3(l.normalizedObjPosition.v, l.objPosition.v);
+        c->transforms.mvui.point4(&c->transforms.mvui,
+                &l.objViewer, &eyeViewer);
+        vnorm3(l.objViewer.v, l.objViewer.v);
     }
 }
 
@@ -379,9 +384,9 @@
             // specular
             if (ggl_unlikely(s && l.implicitSpecular.v[3])) {
                 vec4_t h;
-                h.x = d.x;
-                h.y = d.y;
-                h.z = d.z + 0x10000;
+                h.x = d.x + l.objViewer.x;
+                h.y = d.y + l.objViewer.y;
+                h.z = d.z + l.objViewer.z;
                 vnorm3(h.v, h.v);
                 s = dot3(n.v, h.v);
                 s = (s<0) ? (twoSide?(-s):0) : s;
diff --git a/opengl/libagl/matrix.cpp b/opengl/libagl/matrix.cpp
index 0b68dc0..21ef50e 100644
--- a/opengl/libagl/matrix.cpp
+++ b/opengl/libagl/matrix.cpp
@@ -696,6 +696,8 @@
     f[2] = 0;   f[6] = 0;   f[10] = A;  f[14] = B;
     f[3] = 0;   f[7] = 0;   f[11] = 0;  f[15] = 1;
     c->transforms.dirty |= transform_state_t::VIEWPORT;
+    if (c->transforms.mvp4.flags & transform_t::FLAGS_2D_PROJECTION)
+        c->transforms.dirty |= transform_state_t::MVP;
 }
 
 // ----------------------------------------------------------------------------
diff --git a/opengl/libagl/primitives.cpp b/opengl/libagl/primitives.cpp
index f164c02..769ec40 100644
--- a/opengl/libagl/primitives.cpp
+++ b/opengl/libagl/primitives.cpp
@@ -369,7 +369,7 @@
         int32_t c0, int32_t c1, int32_t c2) const
 {
     int64_t it64[3];
-    iterators0032(it, c0, c1, c2);
+    iterators0032(it64, c0, c1, c2);
     it[0] = it64[0];
     it[1] = it64[1];
     it[2] = it64[2];
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 6dd1175..fa5b8c4 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -56,7 +56,7 @@
  * Database helper class for {@link SettingsProvider}.
  * Mostly just has a bit {@link #onCreate} to initialize the database.
  */
-class DatabaseHelper extends SQLiteOpenHelper {
+public class DatabaseHelper extends SQLiteOpenHelper {
     /**
      * Path to file containing default bookmarks, relative to ANDROID_ROOT.
      */
diff --git a/preloaded-classes b/preloaded-classes
index 69c596c..1b911b9 100644
--- a/preloaded-classes
+++ b/preloaded-classes
@@ -63,14 +63,12 @@
 android.backup.FileBackupHelperBase
 android.bluetooth.BluetoothAudioGateway
 android.bluetooth.BluetoothDevice
-android.bluetooth.Database
 android.bluetooth.HeadsetBase
 android.bluetooth.IBluetoothA2dp
 android.bluetooth.IBluetoothA2dp$Stub
 android.bluetooth.IBluetoothDevice
 android.bluetooth.IBluetoothDevice$Stub
 android.bluetooth.IBluetoothDevice$Stub$Proxy
-android.bluetooth.RfcommSocket
 android.bluetooth.ScoSocket
 android.content.AbstractSyncableContentProvider
 android.content.AbstractTableMerger
@@ -1053,9 +1051,7 @@
 java.util.GregorianCalendar
 java.util.HashMap
 java.util.HashMap$1
-java.util.HashMap$1$1
 java.util.HashMap$Entry
-java.util.HashMap$HashMapIterator
 java.util.HashSet
 java.util.Hashtable
 java.util.Hashtable$1
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 5d34d00..a473db2 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -4021,7 +4021,7 @@
      * @param resultCode Result code, if any, from this Activity.
      * @param resultData Result data (Intent), if any, from this Activity.
      * 
-     * @result Returns true if the activity successfully finished, or false if it is still running.
+     * @return Returns true if the activity successfully finished, or false if it is still running.
      */
     public final boolean finishActivity(IBinder token, int resultCode, Intent resultData) {
         // Refuse possible leaked file descriptors
@@ -5835,6 +5835,7 @@
         }
         // If the target requires a specific UID, always fail for others.
         if (reqUid >= 0 && uid != reqUid) {
+            Log.w(TAG, "Permission denied: checkComponentPermission() reqUid=" + reqUid);
             return PackageManager.PERMISSION_DENIED;
         }
         if (permission == null) {
diff --git a/services/jni/com_android_server_HardwareService.cpp b/services/jni/com_android_server_HardwareService.cpp
index b0aab59..22d4bd8 100644
--- a/services/jni/com_android_server_HardwareService.cpp
+++ b/services/jni/com_android_server_HardwareService.cpp
@@ -133,7 +133,7 @@
 
 static JNINativeMethod method_table[] = {
     { "init_native", "()I", (void*)init_native },
-    { "finalize_native", "(I)V", (void*)init_native },
+    { "finalize_native", "(I)V", (void*)finalize_native },
     { "setLight_native", "(IIIIII)V", (void*)setLight_native },
     { "vibratorOn", "(J)V", (void*)vibratorOn },
     { "vibratorOff", "()V", (void*)vibratorOff }
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 5f80ade..7e6a12c 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -397,7 +397,7 @@
             ResXMLTree tree;
             asset = assets.openNonAsset(resname, Asset::ACCESS_BUFFER);
             if (asset == NULL) {
-                fprintf(stderr, "ERROR: dump failed because resource %p found\n", resname);
+                fprintf(stderr, "ERROR: dump failed because resource %s found\n", resname);
                 goto bail;
             }
 
@@ -423,7 +423,7 @@
             ResXMLTree tree;
             asset = assets.openNonAsset(resname, Asset::ACCESS_BUFFER);
             if (asset == NULL) {
-                fprintf(stderr, "ERROR: dump failed because resource %p found\n", resname);
+                fprintf(stderr, "ERROR: dump failed because resource %s found\n", resname);
                 goto bail;
             }
 
diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp
index 878d3b1..715170a 100644
--- a/tools/aapt/StringPool.cpp
+++ b/tools/aapt/StringPool.cpp
@@ -228,7 +228,7 @@
         }
         dat += (preSize+strPos)/sizeof(uint16_t);
         if (lenSize > sizeof(uint16_t)) {
-            *dat = htods(0x8000 | ((strSize>>16)&0x7ffff));
+            *dat = htods(0x8000 | ((strSize>>16)&0x7fff));
             dat++;
         }
         *dat++ = htods(strSize);
diff --git a/tools/aidl/AST.cpp b/tools/aidl/AST.cpp
index 85ca5da..752ef7c 100755
--- a/tools/aidl/AST.cpp
+++ b/tools/aidl/AST.cpp
@@ -845,23 +845,6 @@
         fprintf(to, "package %s;\n", this->package.c_str());
     }
 
-    // gather the types for the import statements
-    set<Type*> types;
-    N = this->classes.size();
-    for (i=0; i<N; i++) {
-        Class* c = this->classes[i];
-        c->GatherTypes(&types);
-    }
-    
-    set<Type*>::iterator it;
-    for (it=types.begin(); it!=types.end(); it++) {
-        Type* t = *it;
-        string pkg = t->Package();
-        if (pkg.length() != 0 && pkg != this->package) {
-            fprintf(to, "import %s;\n", t->ImportType().c_str());
-        }
-    }
-
     N = this->classes.size();
     for (i=0; i<N; i++) {
         Class* c = this->classes[i];
diff --git a/tools/aidl/generate_java.cpp b/tools/aidl/generate_java.cpp
index 622b691..0f18132 100644
--- a/tools/aidl/generate_java.cpp
+++ b/tools/aidl/generate_java.cpp
@@ -1,6 +1,7 @@
 #include "generate_java.h"
 #include "AST.h"
 #include "Type.h"
+#include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -133,7 +134,7 @@
 
     Method* m = new Method;
         m->comment = "/**\n * Cast an IBinder object into an ";
-        m->comment += interfaceType->Name();
+        m->comment += interfaceType->QualifiedName();
         m->comment += " interface,\n";
         m->comment += " * generating a proxy if needed.\n */";
         m->modifiers = PUBLIC | STATIC;
@@ -323,7 +324,7 @@
     transactCodeName += method->name.data;
 
     char transactCodeValue[50];
-    sprintf(transactCodeValue, "(IBinder.FIRST_CALL_TRANSACTION + %d)", index);
+    sprintf(transactCodeValue, "(android.os.IBinder.FIRST_CALL_TRANSACTION + %d)", index);
 
     Field* transactCode = new Field(STATIC | FINAL,
                             new Variable(INT_TYPE, transactCodeName));
@@ -517,7 +518,7 @@
                             new LiteralExpression("Stub." + transactCodeName),
                             _data, _reply ? _reply : NULL_VALUE,
                             new LiteralExpression(
-                                oneway ? "IBinder.FLAG_ONEWAY" : "0"));
+                                oneway ? "android.os.IBinder.FLAG_ONEWAY" : "0"));
     tryStatement->statements->Add(call);
 
     // throw back exceptions.
diff --git a/tools/aidl/options.h b/tools/aidl/options.h
index e9bf0f7..d88d988 100644
--- a/tools/aidl/options.h
+++ b/tools/aidl/options.h
@@ -1,6 +1,7 @@
 #ifndef DEVICE_TOOLS_AIDL_H
 #define DEVICE_TOOLS_AIDL_H
 
+#include <string.h>
 #include <string>
 #include <vector>
 
diff --git a/tools/localize/Perforce.cpp b/tools/localize/Perforce.cpp
index 1c644ed..ae11231 100644
--- a/tools/localize/Perforce.cpp
+++ b/tools/localize/Perforce.cpp
@@ -6,7 +6,10 @@
 #include <sstream>
 #include <sys/types.h>
 #include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/wait.h>
+#include <cstdio>
 
 using namespace std;
 
diff --git a/tools/localize/SourcePos.cpp b/tools/localize/SourcePos.cpp
index 2533f0a..184bfe0 100644
--- a/tools/localize/SourcePos.cpp
+++ b/tools/localize/SourcePos.cpp
@@ -3,6 +3,7 @@
 #include <stdarg.h>
 #include <cstdio>
 #include <set>
+#include <cstdio>
 
 using namespace std;
 
diff --git a/tools/localize/XMLHandler.h b/tools/localize/XMLHandler.h
index 1130710..324385f 100644
--- a/tools/localize/XMLHandler.h
+++ b/tools/localize/XMLHandler.h
@@ -3,6 +3,7 @@
 
 #include "SourcePos.h"
 
+#include <algorithm>
 #include <string>
 #include <vector>
 #include <map>
diff --git a/tools/localize/file_utils.cpp b/tools/localize/file_utils.cpp
index 293e50e..775ce2f 100644
--- a/tools/localize/file_utils.cpp
+++ b/tools/localize/file_utils.cpp
@@ -8,6 +8,9 @@
 #include <sys/fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <cstdio>
 #include "log.h"
 
 using namespace android;
diff --git a/tools/localize/file_utils.h b/tools/localize/file_utils.h
index 3b3fa21..7706587 100644
--- a/tools/localize/file_utils.h
+++ b/tools/localize/file_utils.h
@@ -4,6 +4,7 @@
 #include "ValuesFile.h"
 #include "Configuration.h"
 #include <string>
+#include <cstdio>
 
 using namespace std;
 
diff --git a/tools/localize/localize.cpp b/tools/localize/localize.cpp
index c0d84cc..68c03b6 100644
--- a/tools/localize/localize.cpp
+++ b/tools/localize/localize.cpp
@@ -15,6 +15,7 @@
 #include <sstream>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 using namespace std;
 
diff --git a/tools/localize/localize_test.cpp b/tools/localize/localize_test.cpp
index 678cad8..1d0ac9a 100644
--- a/tools/localize/localize_test.cpp
+++ b/tools/localize/localize_test.cpp
@@ -1,3 +1,4 @@
+#include <cstdio>
 #include "XLIFFFile.h"
 #include "ValuesFile.h"
 #include "localize.h"
diff --git a/tools/localize/merge_res_and_xliff_test.cpp b/tools/localize/merge_res_and_xliff_test.cpp
index e4ab562..6fe2629 100644
--- a/tools/localize/merge_res_and_xliff_test.cpp
+++ b/tools/localize/merge_res_and_xliff_test.cpp
@@ -1,3 +1,4 @@
+#include <cstdio>
 #include "merge_res_and_xliff.h"
 #include <stdio.h>
 
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 74f4284..e862a7a 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -959,7 +959,7 @@
          *
          * If this MulticastLock is not reference-counted, the first call to
          * {@code release} (after the radio was multicast locked using
-         * {@linke #acquire}) will unlock the multicast, and subsequent calls
+         * {@link #acquire}) will unlock the multicast, and subsequent calls
          * will be ignored.
          *
          * Note that if any other Wifi Multicast Locks are still outstanding