summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/bluetooth
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:43 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:43 -0800
commit8a156091eff22a360f802332daf2fe00b4267ad7 (patch)
tree64baf0ce0e3c9fb39cc086994dbe9805b74e5bca /src/com/android/settings/bluetooth
parent90e190609a1d6894bc8ef102b1cccd3c1578d784 (diff)
downloadpackages_apps_settings-8a156091eff22a360f802332daf2fe00b4267ad7.zip
packages_apps_settings-8a156091eff22a360f802332daf2fe00b4267ad7.tar.gz
packages_apps_settings-8a156091eff22a360f802332daf2fe00b4267ad7.tar.bz2
auto import from //depot/cupcake/@137055
Diffstat (limited to 'src/com/android/settings/bluetooth')
-rw-r--r--src/com/android/settings/bluetooth/BluetoothPinDialog.java7
-rw-r--r--src/com/android/settings/bluetooth/BluetoothSettings.java2
-rw-r--r--src/com/android/settings/bluetooth/ConnectSpecificProfilesActivity.java8
-rw-r--r--src/com/android/settings/bluetooth/LocalBluetoothManager.java35
4 files changed, 42 insertions, 10 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothPinDialog.java b/src/com/android/settings/bluetooth/BluetoothPinDialog.java
index a8e7737..5e289f7 100644
--- a/src/com/android/settings/bluetooth/BluetoothPinDialog.java
+++ b/src/com/android/settings/bluetooth/BluetoothPinDialog.java
@@ -157,11 +157,12 @@ public class BluetoothPinDialog extends AlertActivity implements DialogInterface
messageView.setText(getString(R.string.bluetooth_pairing_error_message,
mLocalManager.getLocalDeviceManager().getName(mAddress)));
- mPinView.setEnabled(false);
+ mPinView.setVisibility(View.GONE);
mPinView.clearFocus();
mPinView.removeTextChangedListener(this);
-
- mAlert.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false);
+
+ mOkButton.setEnabled(true);
+ mAlert.getButton(DialogInterface.BUTTON_NEGATIVE).setVisibility(View.GONE);
}
private void onPair(String pin) {
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index f75e5f5..5adada3 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -253,6 +253,8 @@ public class BluetoothSettings extends PreferenceActivity
// we should start a scan
if (bluetoothState == ExtendedBluetoothState.ENABLED) {
mLocalManager.startScanning(false);
+ } else if (bluetoothState == ExtendedBluetoothState.DISABLED) {
+ mDeviceList.setProgress(false);
}
}
}
diff --git a/src/com/android/settings/bluetooth/ConnectSpecificProfilesActivity.java b/src/com/android/settings/bluetooth/ConnectSpecificProfilesActivity.java
index b4a8ae0..7dd1b70 100644
--- a/src/com/android/settings/bluetooth/ConnectSpecificProfilesActivity.java
+++ b/src/com/android/settings/bluetooth/ConnectSpecificProfilesActivity.java
@@ -217,6 +217,9 @@ public class ConnectSpecificProfilesActivity extends PreferenceActivity
private void refreshOnlineModePreference() {
mOnlineModePreference.setChecked(mOnlineMode);
+ /* Gray out checkbox while connecting and disconnecting */
+ mOnlineModePreference.setEnabled(!mDevice.isBusy());
+
/**
* If the device is online, show status. Otherwise, show a summary that
* describes what the checkbox does.
@@ -244,7 +247,10 @@ public class ConnectSpecificProfilesActivity extends PreferenceActivity
.getProfileManager(mManager, profile);
int connectionStatus = profileManager.getConnectionStatus(address);
-
+
+ /* Gray out checkbox while connecting and disconnecting */
+ profilePref.setEnabled(!mDevice.isBusy());
+
profilePref.setSummary(getProfileSummary(profileManager, profile, address,
connectionStatus, mOnlineMode));
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
index 4fd708e..4671fac 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
@@ -23,6 +23,7 @@ import java.util.List;
import android.app.Activity;
import android.app.AlertDialog;
+import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
@@ -51,11 +52,13 @@ public class LocalBluetoothManager {
private Context mContext;
/** If a BT-related activity is in the foreground, this will be it. */
private Activity mForegroundActivity;
-
+ private AlertDialog mErrorDialog = null;
+
private BluetoothDevice mManager;
private LocalBluetoothDeviceManager mLocalDeviceManager;
private BluetoothEventRedirector mEventRedirector;
+ private BluetoothA2dp mBluetoothA2dp;
public static enum ExtendedBluetoothState { ENABLED, ENABLING, DISABLED, DISABLING, UNKNOWN }
private ExtendedBluetoothState mState = ExtendedBluetoothState.UNKNOWN;
@@ -95,7 +98,9 @@ public class LocalBluetoothManager {
mEventRedirector = new BluetoothEventRedirector(this);
mEventRedirector.start();
-
+
+ mBluetoothA2dp = new BluetoothA2dp(context);
+
return true;
}
@@ -112,6 +117,10 @@ public class LocalBluetoothManager {
}
public void setForegroundActivity(Activity activity) {
+ if (mErrorDialog != null) {
+ mErrorDialog.dismiss();
+ mErrorDialog = null;
+ }
mForegroundActivity = activity;
}
@@ -149,9 +158,23 @@ public class LocalBluetoothManager {
*/
dispatchScanningStateChanged(true);
} else {
-
- // Don't scan more than frequently than SCAN_EXPIRATION_MS, unless forced
- if (!force && mLastScan + SCAN_EXPIRATION_MS > System.currentTimeMillis()) return;
+ if (!force) {
+ // Don't scan more than frequently than SCAN_EXPIRATION_MS,
+ // unless forced
+ if (mLastScan + SCAN_EXPIRATION_MS > System.currentTimeMillis()) {
+ return;
+ }
+
+ // If we are playing music, don't scan unless forced.
+ List<String> sinks = mBluetoothA2dp.listConnectedSinks();
+ if (sinks != null) {
+ for (String address : sinks) {
+ if (mBluetoothA2dp.getSinkState(address) == BluetoothA2dp.STATE_PLAYING) {
+ return;
+ }
+ }
+ }
+ }
if (mManager.startDiscovery(true)) {
mLastScan = System.currentTimeMillis();
@@ -235,7 +258,7 @@ public class LocalBluetoothManager {
if (mForegroundActivity != null) {
// Need an activity context to show a dialog
- AlertDialog ad = new AlertDialog.Builder(mForegroundActivity)
+ mErrorDialog = new AlertDialog.Builder(mForegroundActivity)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(titleResId)
.setMessage(message)