Improve Bluetooth tethering UI usability.

- Updated hint text for BT tethering checkbox to
  "[Sharing|not sharing] this [tablet|phone]'s mobile data connection".
- Show correct hint text when user enters tethering screen.
- Show correct status after user enables tethering when Bluetooth is off.
  When BluetoothPan.setBluetoothTethering(true) is called with BT off,
  BluetoothPanProfileHandler will add a broadcast receiver to enable
  tethering after BT turns on. This happens too late to show the correct
  status when TetherSettings gets the adapter state changed event, so set
  a flag (mBluetoothEnableForTether) instead, and call setBluetoothTethering
  ourselves after the state changes to ON. Also, clear the flag if the
  adapter state changes to OFF or ERROR.
- Show correct status when user enables tethering, then disables Bluetooth,
  then returns to the tethering screen. Previously it would show
  Bluetooth tethering enabled, even though adapter state was OFF.
- Show the number of connected devices in tethering preference screen.
- Distinguish between PANU and NAP in device profiles screen, and show
  appropriate text to clarify the direction of tethering.
- Remove profiles from device profiles list when the device removes the UUID
  (e.g. Mac OS X turning NAP on/off) and after a NAP disconnection when the
  remote device only supports PANU.

Bug: 3414575
Change-Id: I2c0830876d5b9bddb293e57c4d3ca74f105911b8
This commit is contained in:
Jake Hamby
2011-03-04 15:37:39 -08:00
parent 2715376cfa
commit c777ee29c8
11 changed files with 184 additions and 64 deletions

View File

@@ -51,6 +51,13 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
private final List<LocalBluetoothProfile> mProfiles =
new ArrayList<LocalBluetoothProfile>();
// List of profiles that were previously in mProfiles, but have been removed
private final List<LocalBluetoothProfile> mRemovedProfiles =
new ArrayList<LocalBluetoothProfile>();
// Device supports PANU but not NAP: remove PanProfile after device disconnects from NAP
private boolean mLocalNapRoleConnected;
private boolean mVisible;
private final Collection<Callback> mCallbacks = new ArrayList<Callback>();
@@ -100,8 +107,21 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
mProfileConnectionState.put(profile, newProfileState);
if (newProfileState == BluetoothProfile.STATE_CONNECTED) {
if (!mProfiles.contains(profile)) {
mRemovedProfiles.remove(profile);
mProfiles.add(profile);
if (profile instanceof PanProfile &&
((PanProfile) profile).isLocalRoleNap(mDevice)) {
// Device doesn't support NAP, so remove PanProfile on disconnect
mLocalNapRoleConnected = true;
}
}
} else if (mLocalNapRoleConnected && profile instanceof PanProfile &&
((PanProfile) profile).isLocalRoleNap(mDevice) &&
newProfileState == BluetoothProfile.STATE_DISCONNECTED) {
Log.d(TAG, "Removing PanProfile from device after NAP disconnect");
mProfiles.remove(profile);
mRemovedProfiles.add(profile);
mLocalNapRoleConnected = false;
}
}
@@ -391,7 +411,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
ParcelUuid[] localUuids = mLocalAdapter.getUuids();
if (localUuids == null) return false;
mProfileManager.updateProfiles(uuids, localUuids, mProfiles);
mProfileManager.updateProfiles(uuids, localUuids, mProfiles, mRemovedProfiles);
if (DEBUG) {
Log.e(TAG, "updating profiles for " + mDevice.getName());
@@ -482,6 +502,10 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
return connectableProfiles;
}
List<LocalBluetoothProfile> getRemovedProfiles() {
return mRemovedProfiles;
}
void registerCallback(Callback callback) {
synchronized (mCallbacks) {
mCallbacks.add(callback);