From 3f0f998aa72844e487dd189845289d4c5db88b93 Mon Sep 17 00:00:00 2001 From: Jake Hamby Date: Tue, 14 Dec 2010 13:40:10 -0800 Subject: [PATCH] Remove Bluetooth tethering settings screen. Remove obsolete Bluetooth tethering settings screen. BT tethering can be turned on and off, but the connection must be initiated by the remote device. For reverse tethering, there will be a checkbox for that profile in the regular Bluetooth device settings screen. Bug: 3283928 Change-Id: Ic25139f8862b305feb0381e61c24b7783fad2366 --- res/values/strings.xml | 3 - res/xml/tether_prefs.xml | 9 --- src/com/android/settings/TetherSettings.java | 17 ----- .../bluetooth/BluetoothEventRedirector.java | 3 + .../settings/bluetooth/BluetoothSettings.java | 89 ++++------------------ 5 files changed, 18 insertions(+), 103 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 8bc413996f..e18fdc3ad4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1728,9 +1728,6 @@ %1$s will be untethered. - Bluetooth tethering settings - Select Bluetooth devices to tether - Help diff --git a/res/xml/tether_prefs.xml b/res/xml/tether_prefs.xml index d475a1445d..f16200db4f 100644 --- a/res/xml/tether_prefs.xml +++ b/res/xml/tether_prefs.xml @@ -38,15 +38,6 @@ android:title="@string/bluetooth_tether_checkbox_text" android:persistent="false" /> - - - - diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java index bc27dc025c..81d23ab3eb 100644 --- a/src/com/android/settings/TetherSettings.java +++ b/src/com/android/settings/TetherSettings.java @@ -51,7 +51,6 @@ public class TetherSettings extends SettingsPreferenceFragment { private static final String ENABLE_WIFI_AP = "enable_wifi_ap"; private static final String WIFI_AP_SETTINGS = "wifi_ap_settings"; private static final String ENABLE_BLUETOOTH_TETHERING = "enable_bluetooth_tethering"; - private static final String BLUETOOTH_TETHER_SETTINGS = "bluetooth_tether_settings"; private static final String TETHERING_HELP = "tethering_help"; private static final String USB_HELP_MODIFIER = "usb_"; private static final String WIFI_HELP_MODIFIER = "wifi_"; @@ -68,7 +67,6 @@ public class TetherSettings extends SettingsPreferenceFragment { private WifiApEnabler mWifiApEnabler; private CheckBoxPreference mBluetoothTether; - private PreferenceScreen mBluetoothSettings; private PreferenceScreen mTetherHelp; @@ -97,7 +95,6 @@ public class TetherSettings extends SettingsPreferenceFragment { mWifiApSettings = (PreferenceScreen) findPreference(WIFI_AP_SETTINGS); mUsbTether = (CheckBoxPreference) findPreference(USB_TETHER_SETTINGS); mBluetoothTether = (CheckBoxPreference) findPreference(ENABLE_BLUETOOTH_TETHERING); - mBluetoothSettings = (PreferenceScreen) findPreference(BLUETOOTH_TETHER_SETTINGS); mTetherHelp = (PreferenceScreen) findPreference(TETHERING_HELP); ConnectivityManager cm = @@ -121,14 +118,11 @@ public class TetherSettings extends SettingsPreferenceFragment { } if (!bluetoothAvailable) { getPreferenceScreen().removePreference(mBluetoothTether); - getPreferenceScreen().removePreference(mBluetoothSettings); } else { if (mBluetoothPan.isTetheringOn()) { mBluetoothTether.setChecked(true); - mBluetoothSettings.setEnabled(true); } else { mBluetoothTether.setChecked(false); - mBluetoothSettings.setEnabled(false); } } /* Don't change the title for two-pane settings @@ -360,17 +354,14 @@ public class TetherSettings extends SettingsPreferenceFragment { int btState = adapter.getState(); if (btState == BluetoothAdapter.STATE_TURNING_OFF) { mBluetoothTether.setEnabled(false); - mBluetoothSettings.setEnabled(false); mBluetoothTether.setSummary(R.string.wifi_stopping); } else if (btState == BluetoothAdapter.STATE_TURNING_ON) { mBluetoothTether.setEnabled(false); - mBluetoothSettings.setEnabled(false); mBluetoothTether.setSummary(R.string.bluetooth_turning_on); } else if (mBluetoothPan.isTetheringOn()) { mBluetoothTether.setChecked(true); if (btState == BluetoothAdapter.STATE_ON) { mBluetoothTether.setEnabled(true); - mBluetoothSettings.setEnabled(true); if (bluetoothTethered) { mBluetoothTether.setSummary(R.string.bluetooth_tethering_connected_subtext); } else if (bluetoothErrored) { @@ -382,7 +373,6 @@ public class TetherSettings extends SettingsPreferenceFragment { } else { mBluetoothTether.setEnabled(true); mBluetoothTether.setChecked(false); - mBluetoothSettings.setEnabled(false); mBluetoothTether.setSummary(R.string.bluetooth_tethering_off_subtext); } } @@ -433,9 +423,6 @@ public class TetherSettings extends SettingsPreferenceFragment { adapter.enable(); mBluetoothTether.setSummary(R.string.bluetooth_turning_on); mBluetoothTether.setEnabled(false); - mBluetoothSettings.setEnabled(false); - } else { - mBluetoothSettings.setEnabled(true); } mBluetoothPan.setBluetoothTethering(true); @@ -453,16 +440,12 @@ public class TetherSettings extends SettingsPreferenceFragment { } mBluetoothPan.setBluetoothTethering(false); - mBluetoothSettings.setEnabled(false); if (errored) { mBluetoothTether.setSummary(R.string.bluetooth_tethering_errored_subtext); } else { mBluetoothTether.setSummary(R.string.bluetooth_tethering_off_subtext); } } - } else if (preference == mBluetoothSettings) { - preference.getExtras().putString(BluetoothSettings.ACTION, - BluetoothSettings.ACTION_LAUNCH_TETHER_PICKER); } else if (preference == mTetherHelp) { showDialog(DIALOG_TETHER_HELP); return true; diff --git a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java index 3042e3deb8..57e359d10d 100644 --- a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java +++ b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java @@ -142,6 +142,8 @@ public class BluetoothEventRedirector { Profile.HID, newState); } else if (action.equals(BluetoothPan.ACTION_PAN_STATE_CHANGED)) { + // TODO: uncomment and execute for reverse tethering only +/* final int newState = intent.getIntExtra( BluetoothPan.EXTRA_PAN_STATE, 0); final int oldState = intent.getIntExtra( @@ -152,6 +154,7 @@ public class BluetoothEventRedirector { } mManager.getCachedDeviceManager().onProfileStateChanged(device, Profile.PAN, newState); +*/ } else if (action.equals(BluetoothDevice.ACTION_CLASS_CHANGED)) { mManager.getCachedDeviceManager().onBtClassChanged(device); diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index aae13115a4..89efd72cb8 100644 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -42,6 +42,7 @@ import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; import android.text.TextUtils; +import android.util.Log; import android.view.View; import java.util.List; @@ -65,24 +66,21 @@ public class BluetoothSettings extends SettingsPreferenceFragment private static final int SCREEN_TYPE_SETTINGS = 0; private static final int SCREEN_TYPE_DEVICEPICKER = 1; - private static final int SCREEN_TYPE_TETHERING = 2; - private static final int SCREEN_TYPE_SCAN = 3; + private static final int SCREEN_TYPE_SCAN = 2; public static final String ACTION = "bluetooth_action"; - public static final String ACTION_LAUNCH_TETHER_PICKER = - "com.android.settings.bluetooth.action.LAUNCH_TETHER_PICKER"; public static final String ACTION_LAUNCH_SCAN_MODE = "com.android.settings.bluetooth.action.LAUNCH_SCAN_MODE"; - private int mScreenType; + /*package*/ int mScreenType; private int mFilterType; private boolean mNeedAuth; private String mLaunchPackage; private String mLaunchClass; - private BluetoothDevice mSelectedDevice= null; + /*package*/ BluetoothDevice mSelectedDevice= null; - private LocalBluetoothManager mLocalManager; + /*package*/ LocalBluetoothManager mLocalManager; private BluetoothEnabler mEnabler; private BluetoothDiscoverableEnabler mDiscoverableEnabler; @@ -111,8 +109,6 @@ public class BluetoothSettings extends SettingsPreferenceFragment if (mScreenType == SCREEN_TYPE_DEVICEPICKER) { sendDevicePickedIntent(device); finish(); - } else if (mScreenType == SCREEN_TYPE_TETHERING) { - onPanDevicePicked(); } else if (mScreenType == SCREEN_TYPE_SCAN) { finish(); } @@ -168,12 +164,6 @@ public class BluetoothSettings extends SettingsPreferenceFragment activity.setTitle(activity.getString(R.string.device_picker)); addPreferencesFromResource(R.xml.device_picker); - } else if (action.equals(ACTION_LAUNCH_TETHER_PICKER)) { - mScreenType = SCREEN_TYPE_TETHERING; - mFilterType = BluetoothDevicePicker.FILTER_TYPE_PANU; - - activity.setTitle(activity.getString(R.string.device_picker)); - addPreferencesFromResource(R.xml.device_picker); } else if (action.equals(ACTION_LAUNCH_SCAN_MODE)) { mScreenType = SCREEN_TYPE_SCAN; @@ -293,15 +283,9 @@ public class BluetoothSettings extends SettingsPreferenceFragment } else { btPreference.getCachedDevice().onClicked(); } - } else if (mScreenType == SCREEN_TYPE_TETHERING) { - mLocalManager.stopScanning(); - mLocalManager.persistSelectedDeviceInPicker(mSelectedDevice.getAddress()); - if ((device.getBondState() == BluetoothDevice.BOND_BONDED)) { - onPanDevicePicked(); - // don't call finish so that users can see it connecting - } else { - btPreference.getCachedDevice().onClicked(); - } + } else { + Log.e(TAG, "onPreferenceTreeClick has invalid mScreenType: " + + mScreenType); } return true; } @@ -391,14 +375,10 @@ public class BluetoothSettings extends SettingsPreferenceFragment } private void createDevicePreference(CachedBluetoothDevice cachedDevice) { - BluetoothDevicePreference preference; - if (mScreenType == SCREEN_TYPE_TETHERING) { - preference = new BluetoothDevicePreference( - getActivity(), cachedDevice, CachedBluetoothDevice.PAN_PROFILE); - } else { - preference = new BluetoothDevicePreference( - getActivity(), cachedDevice, CachedBluetoothDevice.OTHER_PROFILES); - } + BluetoothDevicePreference preference = new BluetoothDevicePreference( + getActivity(), cachedDevice, + CachedBluetoothDevice.OTHER_PROFILES); + if (mScreenType == SCREEN_TYPE_SETTINGS) { preference.setOnSettingsClickListener(this); } @@ -422,7 +402,8 @@ public class BluetoothSettings extends SettingsPreferenceFragment ((ProgressCategory) mDeviceList).setProgress(start); } } - private void onBluetoothStateChanged(int bluetoothState) { + + /*package*/ void onBluetoothStateChanged(int bluetoothState) { // When bluetooth is enabled (and we are in the activity, which we are), // we should start a scan if (bluetoothState == BluetoothAdapter.STATE_ON) { @@ -434,47 +415,7 @@ public class BluetoothSettings extends SettingsPreferenceFragment } } - private void onPanDevicePicked() { - final Activity activity = getActivity(); - final LocalBluetoothProfileManager profileManager = - LocalBluetoothProfileManager.getProfileManager(mLocalManager, Profile.PAN); - int status = profileManager.getConnectionStatus(mSelectedDevice); - if (SettingsBtStatus.isConnectionStatusConnected(status)) { - String name = mSelectedDevice.getName(); - if (TextUtils.isEmpty(name)) { - name = activity.getString(R.string.bluetooth_device); - } - String message = activity.getString(R.string.bluetooth_untether_blank, name); - DialogInterface.OnClickListener disconnectListener = - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - profileManager.disconnect(mSelectedDevice); - } - }; - new AlertDialog.Builder(activity) - .setTitle(name) - .setMessage(message) - .setPositiveButton(android.R.string.ok, disconnectListener) - .setNegativeButton(android.R.string.cancel, null) - .create() - .show(); - } else if (status == SettingsBtStatus.CONNECTION_STATUS_DISCONNECTED) { - if (profileManager.getConnectedDevices().size() >= BluetoothPan.MAX_CONNECTIONS) { - new AlertDialog.Builder(activity) - .setIcon(android.R.drawable.ic_dialog_alert) - .setTitle(R.string.bluetooth_error_title) - .setMessage(activity.getString(R.string.bluetooth_tethering_overflow_error, - BluetoothPan.MAX_CONNECTIONS)) - .setNegativeButton(android.R.string.ok, null) - .create() - .show(); - return; - } - profileManager.connect(mSelectedDevice); - } - } - - private void sendDevicePickedIntent(BluetoothDevice device) { + /*package*/ void sendDevicePickedIntent(BluetoothDevice device) { Intent intent = new Intent(BluetoothDevicePicker.ACTION_DEVICE_SELECTED); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); if (mScreenType == SCREEN_TYPE_DEVICEPICKER && -- 2.11.0