auto import from //branches/cupcake/...@127101
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
@@ -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;
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user