Merge "Add operands to mifare classic increment, decrement." into gingerbread
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
index 954fde5..f6d7073 100644
--- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java
+++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
@@ -75,6 +75,7 @@
     public static final int CONNECT_OTHER_PROFILES = 103;
 
     private static final int AUTO_CONNECT_DELAY = 6000; // 6 secs
+    private static final int CONNECT_OTHER_PROFILES_DELAY = 4000; // 4 secs
 
     private BondedDevice mBondedDevice = new BondedDevice();
     private OutgoingHandsfree mOutgoingHandsfree = new OutgoingHandsfree();
@@ -765,23 +766,26 @@
             case CONNECT_HFP_INCOMING:
                 // Connect A2DP if there is no incoming connection
                 // If the priority is OFF - don't auto connect.
-                // If the priority is AUTO_CONNECT, auto connect code takes care.
-                if (mA2dpService.getSinkPriority(mDevice) == BluetoothA2dp.PRIORITY_ON) {
+                if (mA2dpService.getSinkPriority(mDevice) == BluetoothA2dp.PRIORITY_ON ||
+                        mA2dpService.getSinkPriority(mDevice) ==
+                            BluetoothA2dp.PRIORITY_AUTO_CONNECT) {
                     Message msg = new Message();
                     msg.what = CONNECT_OTHER_PROFILES;
                     msg.arg1 = CONNECT_A2DP_OUTGOING;
-                    sendMessageDelayed(msg, AUTO_CONNECT_DELAY);
+                    sendMessageDelayed(msg, CONNECT_OTHER_PROFILES_DELAY);
                 }
                 break;
             case CONNECT_A2DP_INCOMING:
                 // This is again against spec. HFP incoming connections should be made
                 // before A2DP, so we should not hit this case. But many devices
                 // don't follow this.
-                if (mHeadsetService.getPriority(mDevice) == BluetoothHeadset.PRIORITY_ON) {
+                if (mHeadsetService.getPriority(mDevice) == BluetoothHeadset.PRIORITY_ON
+                        || mHeadsetService.getPriority(mDevice) ==
+                            BluetoothHeadset.PRIORITY_AUTO_CONNECT) {
                     Message msg = new Message();
                     msg.what = CONNECT_OTHER_PROFILES;
                     msg.arg1 = CONNECT_HFP_OUTGOING;
-                    sendMessageDelayed(msg, AUTO_CONNECT_DELAY);
+                    sendMessageDelayed(msg, CONNECT_OTHER_PROFILES_DELAY);
                 }
                 break;
             default:
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index b1623a5..f38bed9 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -26,7 +26,6 @@
 import android.content.IntentFilter;
 import android.content.pm.IPackageManager;
 import android.content.pm.PackageManager;
-import android.nfc.tech.TagTechnology;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.os.ServiceManager;
@@ -416,18 +415,19 @@
     /**
      * Enables foreground dispatching to the given Activity. This will force all NFC Intents that
      * match the given filters to be delivered to the activity bypassing the standard dispatch
-     * mechanism.
+     * mechanism. If no IntentFilters are given all the PendingIntent will be invoked for every
+     * dispatch Intent.
      *
      * This method must be called from the main thread.
      *
      * @param activity the Activity to dispatch to
      * @param intent the PendingIntent to start for the dispatch
-     * @param filters the IntentFilters to override dispatching for
+     * @param filters the IntentFilters to override dispatching for, or null to always dispatch
      * @throws IllegalStateException
      */
     public void enableForegroundDispatch(Activity activity, PendingIntent intent,
             IntentFilter... filters) {
-        if (activity == null || intent == null || filters == null) {
+        if (activity == null || intent == null) {
             throw new NullPointerException();
         }
         if (!activity.isResumed()) {
@@ -478,7 +478,13 @@
     }
 
     /**
-     * Enable NDEF messages push while this Activity is in the foreground.
+     * Enable NDEF message push over P2P while this Activity is in the foreground. For this to
+     * function properly the other NFC device being scanned must support the "com.android.npp"
+     * NDEF push protocol.
+     *
+     * <p><em>NOTE</em> While foreground NDEF push is active standard tag dispatch is disabled.
+     * Only the foreground activity may receive tag discovered dispatches via
+     * {@link #enableForegroundDispatch}.
      */
     public void enableForegroundNdefPush(Activity activity, NdefMessage msg) {
         if (activity == null || msg == null) {
diff --git a/core/java/android/webkit/WebIconDatabase.java b/core/java/android/webkit/WebIconDatabase.java
index bb9ec48..54dfab3 100644
--- a/core/java/android/webkit/WebIconDatabase.java
+++ b/core/java/android/webkit/WebIconDatabase.java
@@ -24,6 +24,7 @@
 import android.provider.Browser;
 import android.util.Log;
 
+import java.io.File;
 import java.util.HashMap;
 import java.util.Vector;
 
@@ -194,13 +195,16 @@
     /**
      * Open a the icon database and store the icons in the given path.
      * @param path The directory path where the icon database will be stored.
-     * @return True if the database was successfully opened or created in
-     *         the given path.
      */
     public void open(String path) {
         if (path != null) {
+            // Make the directories and parents if they don't exist
+            File db = new File(path);
+            if (!db.exists()) {
+                db.mkdirs();
+            }
             mEventHandler.postMessage(
-                    Message.obtain(null, EventHandler.OPEN, path));
+                    Message.obtain(null, EventHandler.OPEN, db.getAbsolutePath()));
         }
     }
 
diff --git a/core/java/com/android/internal/widget/DigitalClock.java b/core/java/com/android/internal/widget/DigitalClock.java
index 303a1bf..7289751 100644
--- a/core/java/com/android/internal/widget/DigitalClock.java
+++ b/core/java/com/android/internal/widget/DigitalClock.java
@@ -80,7 +80,11 @@
                     }
                 });
             } else {
-                mContext.unregisterReceiver(this);
+                try {
+                    mContext.unregisterReceiver(this);
+                } catch (RuntimeException e) {
+                    // Shouldn't happen
+                }
             }
         }
     };
@@ -124,7 +128,11 @@
                 digitalClock.setDateFormat();
                 digitalClock.updateTime();
             } else {
-                mContext.getContentResolver().unregisterContentObserver(this);
+                try {
+                    mContext.getContentResolver().unregisterContentObserver(this);
+                } catch (RuntimeException e) {
+                    // Shouldn't happen
+                }
             }
         }
     }