auto import from //branches/cupcake/...@127101
diff --git a/res/drawable/ic_menu_archive.png b/res/drawable/ic_menu_archive.png
deleted file mode 100644
index a4599e3..0000000
--- a/res/drawable/ic_menu_archive.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/ic_menu_goto.png b/res/drawable/ic_menu_goto.png
deleted file mode 100644
index 40183ebc..0000000
--- a/res/drawable/ic_menu_goto.png
+++ /dev/null
Binary files differ
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 76248b4..f75e5f5 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -147,7 +147,7 @@
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         menu.add(0, MENU_SCAN, 0, R.string.bluetooth_scan_for_devices)
-                .setIcon(android.R.drawable.ic_menu_refresh)
+                .setIcon(com.android.internal.R.drawable.ic_menu_refresh)
                 .setAlphabeticShortcut('r');
         return true;
     }
diff --git a/src/com/android/settings/bluetooth/ConnectSpecificProfilesActivity.java b/src/com/android/settings/bluetooth/ConnectSpecificProfilesActivity.java
index f29ec79..23a43bd 100644
--- a/src/com/android/settings/bluetooth/ConnectSpecificProfilesActivity.java
+++ b/src/com/android/settings/bluetooth/ConnectSpecificProfilesActivity.java
@@ -181,8 +181,9 @@
             }
         }
         
-        LocalBluetoothProfileManager.setPreferredProfile(this, mDevice.getAddress(), profile,
-                checked);
+        LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager
+                .getProfileManager(mManager, profile);
+        profileManager.setPreferred(mDevice.getAddress(), checked);
     }
     
     public void onDeviceAttributesChanged(LocalBluetoothDevice device) {
@@ -252,8 +253,7 @@
         profilePref.setSummary(getProfileSummary(profileManager, profile, address,
                 connectionStatus, mOnlineMode));
         
-        profilePref.setChecked(
-                LocalBluetoothProfileManager.isPreferredProfile(this, address, profile));
+        profilePref.setChecked(profileManager.isPreferred(address));
     }
 
     private Profile getProfileOf(Preference pref) {
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothDevice.java b/src/com/android/settings/bluetooth/LocalBluetoothDevice.java
index a8f79ff..77522f3 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothDevice.java
@@ -147,7 +147,9 @@
         Context context = mLocalManager.getContext();
         boolean hasAtLeastOnePreferredProfile = false;
         for (Profile profile : mProfiles) {
-            if (LocalBluetoothProfileManager.isPreferredProfile(context, mAddress, profile)) {
+            LocalBluetoothProfileManager profileManager =
+                    LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
+            if (profileManager.isPreferred(mAddress)) {
                 hasAtLeastOnePreferredProfile = true;
                 connect(profile);
             }
@@ -163,7 +165,9 @@
         
         Context context = mLocalManager.getContext();
         for (Profile profile : mProfiles) {
-            LocalBluetoothProfileManager.setPreferredProfile(context, mAddress, profile, true);
+            LocalBluetoothProfileManager profileManager =
+                    LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
+            profileManager.setPreferred(mAddress, true);
             connect(profile);
         }
     }
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
index f9b51d6..a1a2af6 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
@@ -69,26 +69,6 @@
         return profileManager;
     }
 
-    // TODO: remove once the framework has this API
-    public static boolean isPreferredProfile(Context context, String address, Profile profile) {
-        return getPreferredProfileSharedPreferences(context).getBoolean(
-                getPreferredProfileKey(address, profile), true);
-    }
-    
-    public static void setPreferredProfile(Context context, String address, Profile profile,
-            boolean preferred) {
-        getPreferredProfileSharedPreferences(context).edit().putBoolean(
-                getPreferredProfileKey(address, profile), preferred).commit();
-    }
-
-    private static SharedPreferences getPreferredProfileSharedPreferences(Context context) {
-        return context.getSharedPreferences("bluetooth_preferred_profiles", Context.MODE_PRIVATE);
-    }
-    
-    private static String getPreferredProfileKey(String address, Profile profile) {
-        return address + "_" + profile.toString();
-    }
-    
     /**
      * Temporary method to fill profiles based on a device's class.
      * 
@@ -98,11 +78,11 @@
     public static void fill(int btClass, List<Profile> profiles) {
         profiles.clear();
 
-        if (A2dpProfileManager.doesClassMatch(btClass)) {
+        if (BluetoothA2dp.doesClassMatchSink(btClass)) {
             profiles.add(Profile.A2DP);
         }
         
-        if (HeadsetProfileManager.doesClassMatch(btClass)) {
+        if (BluetoothHeadset.doesClassMatch(btClass)) {
             profiles.add(Profile.HEADSET);
         }
     }
@@ -119,6 +99,10 @@
 
     public abstract int getSummary(String address);
 
+    public abstract boolean isPreferred(String address);
+
+    public abstract void setPreferred(String address, boolean preferred);
+
     public boolean isConnected(String address) {
         return SettingsBtStatus.isConnectionStatusConnected(getConnectionStatus(address));
     }
@@ -156,26 +140,6 @@
             return mService.disconnectSink(address);
         }
         
-        static boolean doesClassMatch(int btClass) {
-            if (BluetoothClass.Service.hasService(btClass, BluetoothClass.Service.RENDER)) {
-                return true;
-            }
-
-            // By the specification A2DP sinks must indicate the RENDER service
-            // class, but some do not (Chordette). So match on a few more to be
-            // safe
-            switch (BluetoothClass.Device.getDevice(btClass)) {
-            case BluetoothClass.Device.AUDIO_VIDEO_HIFI_AUDIO:
-            case BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES:
-            case BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER:
-            case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO:
-                return true;
-                
-            default:
-                return false;
-            }
-        }
-
         @Override
         public int getConnectionStatus(String address) {
             return convertState(mService.getSinkState(address));
@@ -184,7 +148,7 @@
         @Override
         public int getSummary(String address) {
             int connectionStatus = getConnectionStatus(address);
-            
+
             if (SettingsBtStatus.isConnectionStatusConnected(connectionStatus)) {
                 return R.string.bluetooth_a2dp_profile_summary_connected;
             } else {
@@ -192,6 +156,17 @@
             }
         }
 
+        @Override
+        public boolean isPreferred(String address) {
+            return mService.getSinkPriority(address) > BluetoothA2dp.PRIORITY_OFF;
+        }
+
+        @Override
+        public void setPreferred(String address, boolean preferred) {
+            mService.setSinkPriority(address,
+                    preferred ? BluetoothA2dp.PRIORITY_AUTO : BluetoothA2dp.PRIORITY_OFF);
+        }
+
         private static int convertState(int a2dpState) {
             switch (a2dpState) {
             case BluetoothA2dp.STATE_CONNECTED:
@@ -246,7 +221,7 @@
             // Since connectHeadset fails if already connected to a headset, we
             // disconnect from any headset first
             mService.disconnectHeadset();
-            return mService.connectHeadset(address, null)
+            return mService.connectHeadset(address)
                     ? BluetoothError.SUCCESS : BluetoothError.ERROR;
         }
 
@@ -259,18 +234,6 @@
             }
         }
         
-        static boolean doesClassMatch(int btClass) {
-            switch (BluetoothClass.Device.getDevice(btClass)) {
-            case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE:
-            case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET:
-            case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO:
-                return true;
-                
-            default:
-                return false;
-            }
-        }
-
         @Override
         public int getConnectionStatus(String address) {
             String headsetAddress = mService.getHeadsetAddress();
@@ -290,6 +253,17 @@
             }
         }
 
+        @Override
+        public boolean isPreferred(String address) {
+            return mService.getPriority(address) > BluetoothHeadset.PRIORITY_OFF;
+        }
+
+        @Override
+        public void setPreferred(String address, boolean preferred) {
+            mService.setPriority(address,
+                    preferred ? BluetoothHeadset.PRIORITY_AUTO : BluetoothHeadset.PRIORITY_OFF);
+        }
+
         private static int convertState(int headsetState) {
             switch (headsetState) {
             case BluetoothHeadset.STATE_CONNECTED:
@@ -303,5 +277,4 @@
             }
         }
     }
-    
 }
diff --git a/src/com/android/settings/quicklaunch/BookmarkPicker.java b/src/com/android/settings/quicklaunch/BookmarkPicker.java
index 5c5ab40..7152abb 100644
--- a/src/com/android/settings/quicklaunch/BookmarkPicker.java
+++ b/src/com/android/settings/quicklaunch/BookmarkPicker.java
@@ -101,9 +101,9 @@
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         menu.add(0, DISPLAY_MODE_LAUNCH, 0, R.string.quick_launch_display_mode_applications)
-                .setIcon(R.drawable.ic_menu_archive);
+                .setIcon(com.android.internal.R.drawable.ic_menu_archive);
         menu.add(0, DISPLAY_MODE_SHORTCUT, 0, R.string.quick_launch_display_mode_shortcuts)
-                .setIcon(R.drawable.ic_menu_goto);
+                .setIcon(com.android.internal.R.drawable.ic_menu_goto);
         return true;
     }