diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-20 14:04:01 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-20 14:04:01 -0800 |
commit | 01f172366c86623cc45a1b9a810dda86c595eb19 (patch) | |
tree | b1940c5f033ed81b538db1762b8467667a0a0136 | |
parent | 1152aff9d0767e528aa4a40cc8acb51b9c21d2e7 (diff) | |
download | packages_apps_Settings-01f172366c86623cc45a1b9a810dda86c595eb19.zip packages_apps_Settings-01f172366c86623cc45a1b9a810dda86c595eb19.tar.gz packages_apps_Settings-01f172366c86623cc45a1b9a810dda86c595eb19.tar.bz2 |
auto import from //branches/cupcake/...@127101
-rw-r--r-- | res/drawable/ic_menu_archive.png | bin | 1354 -> 0 bytes | |||
-rw-r--r-- | res/drawable/ic_menu_goto.png | bin | 1636 -> 0 bytes | |||
-rw-r--r-- | src/com/android/settings/bluetooth/BluetoothSettings.java | 2 | ||||
-rw-r--r-- | src/com/android/settings/bluetooth/ConnectSpecificProfilesActivity.java | 8 | ||||
-rw-r--r-- | src/com/android/settings/bluetooth/LocalBluetoothDevice.java | 8 | ||||
-rw-r--r-- | src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java | 87 | ||||
-rw-r--r-- | src/com/android/settings/quicklaunch/BookmarkPicker.java | 4 |
7 files changed, 43 insertions, 66 deletions
diff --git a/res/drawable/ic_menu_archive.png b/res/drawable/ic_menu_archive.png Binary files differdeleted file mode 100644 index a4599e3..0000000 --- a/res/drawable/ic_menu_archive.png +++ /dev/null diff --git a/res/drawable/ic_menu_goto.png b/res/drawable/ic_menu_goto.png Binary files differdeleted file mode 100644 index 40183eb..0000000 --- a/res/drawable/ic_menu_goto.png +++ /dev/null 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 @@ public class BluetoothSettings extends PreferenceActivity @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 @@ public class ConnectSpecificProfilesActivity extends PreferenceActivity } } - 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 @@ public class ConnectSpecificProfilesActivity extends PreferenceActivity 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 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> { 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 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> { 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 @@ public abstract class LocalBluetoothProfileManager { 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 abstract class LocalBluetoothProfileManager { 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 class LocalBluetoothProfileManager { 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 @@ public abstract class LocalBluetoothProfileManager { 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 @@ public abstract class LocalBluetoothProfileManager { @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 @@ public abstract class LocalBluetoothProfileManager { } } + @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 @@ public abstract class LocalBluetoothProfileManager { // 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 @@ public abstract class LocalBluetoothProfileManager { } } - 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 @@ public abstract class LocalBluetoothProfileManager { } } + @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 @@ public abstract class LocalBluetoothProfileManager { } } } - } 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 @@ public class BookmarkPicker extends ListActivity implements SimpleAdapter.ViewBi @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; } |