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

@@ -25,14 +25,19 @@ import android.content.Context;
import com.android.settings.R;
import java.util.HashMap;
import java.util.List;
/**
* PanProfile handles Bluetooth PAN profile.
* PanProfile handles Bluetooth PAN profile (NAP and PANU).
*/
final class PanProfile implements LocalBluetoothProfile {
private BluetoothPan mService;
// Tethering direction for each device
private final HashMap<BluetoothDevice, Integer> mDeviceRoleMap =
new HashMap<BluetoothDevice, Integer>();
static final String NAME = "PAN";
// Order of this profile in device profiles list
@@ -111,8 +116,12 @@ final class PanProfile implements LocalBluetoothProfile {
return R.string.bluetooth_profile_pan;
}
public int getDisconnectResource() {
return R.string.bluetooth_disconnect_pan_profile;
public int getDisconnectResource(BluetoothDevice device) {
if (isLocalRoleNap(device)) {
return R.string.bluetooth_disconnect_pan_nap_profile;
} else {
return R.string.bluetooth_disconnect_pan_user_profile;
}
}
public int getSummaryResourceForDevice(BluetoothDevice device) {
@@ -122,7 +131,11 @@ final class PanProfile implements LocalBluetoothProfile {
return R.string.bluetooth_pan_profile_summary_use_for;
case BluetoothProfile.STATE_CONNECTED:
return R.string.bluetooth_pan_profile_summary_connected;
if (isLocalRoleNap(device)) {
return R.string.bluetooth_pan_nap_profile_summary_connected;
} else {
return R.string.bluetooth_pan_user_profile_summary_connected;
}
default:
return Utils.getConnectionStateSummary(state);
@@ -132,4 +145,17 @@ final class PanProfile implements LocalBluetoothProfile {
public int getDrawableResource(BluetoothClass btClass) {
return R.drawable.ic_bt_network_pan;
}
// Tethering direction determines UI strings.
void setLocalRole(BluetoothDevice device, int role) {
mDeviceRoleMap.put(device, role);
}
boolean isLocalRoleNap(BluetoothDevice device) {
if (mDeviceRoleMap.containsKey(device)) {
return mDeviceRoleMap.get(device) == BluetoothPan.LOCAL_NAP_ROLE;
} else {
return false;
}
}
}