auto import from //depot/cupcake/@137055
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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));
|
||||
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user