Merge commit '8a6730df320b2fa10ac11ea1aad06d85bbed31e4' * commit '8a6730df320b2fa10ac11ea1aad06d85bbed31e4': Update application for Bluetooth API change: deprecation of BluetoothError.
This commit is contained in:
@@ -19,7 +19,6 @@ package com.android.settings.bluetooth;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.bluetooth.BluetoothIntent;
|
import android.bluetooth.BluetoothIntent;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -56,8 +55,9 @@ public class BluetoothDiscoverableEnabler implements Preference.OnPreferenceChan
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (BluetoothAdapter.ACTION_SCAN_MODE_CHANGED.equals(intent.getAction())) {
|
if (BluetoothAdapter.ACTION_SCAN_MODE_CHANGED.equals(intent.getAction())) {
|
||||||
int mode = intent.getIntExtra(BluetoothAdapter.EXTRA_SCAN_MODE, BluetoothError.ERROR);
|
int mode = intent.getIntExtra(BluetoothAdapter.EXTRA_SCAN_MODE,
|
||||||
if (mode != BluetoothError.ERROR) {
|
BluetoothAdapter.ERROR);
|
||||||
|
if (mode != BluetoothAdapter.ERROR) {
|
||||||
handleModeChanged(mode);
|
handleModeChanged(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,6 @@ package com.android.settings.bluetooth;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.bluetooth.BluetoothIntent;
|
import android.bluetooth.BluetoothIntent;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -49,8 +48,7 @@ public class BluetoothEnabler implements Preference.OnPreferenceChangeListener {
|
|||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
|
||||||
BluetoothError.ERROR);
|
|
||||||
handleStateChanged(state);
|
handleStateChanged(state);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -20,7 +20,6 @@ import android.bluetooth.BluetoothA2dp;
|
|||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.bluetooth.BluetoothHeadset;
|
import android.bluetooth.BluetoothHeadset;
|
||||||
import android.bluetooth.BluetoothIntent;
|
import android.bluetooth.BluetoothIntent;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -54,7 +53,7 @@ public class BluetoothEventRedirector {
|
|||||||
|
|
||||||
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
||||||
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
||||||
BluetoothError.ERROR);
|
BluetoothAdapter.ERROR);
|
||||||
mManager.setBluetoothStateInt(state);
|
mManager.setBluetoothStateInt(state);
|
||||||
} else if (action.equals(BluetoothIntent.DISCOVERY_STARTED_ACTION)) {
|
} else if (action.equals(BluetoothIntent.DISCOVERY_STARTED_ACTION)) {
|
||||||
mManager.onScanningStateChanged(true);
|
mManager.onScanningStateChanged(true);
|
||||||
@@ -76,10 +75,10 @@ public class BluetoothEventRedirector {
|
|||||||
|
|
||||||
} else if (action.equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)) {
|
} else if (action.equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)) {
|
||||||
int bondState = intent.getIntExtra(BluetoothIntent.BOND_STATE,
|
int bondState = intent.getIntExtra(BluetoothIntent.BOND_STATE,
|
||||||
BluetoothError.ERROR);
|
BluetoothDevice.ERROR);
|
||||||
mManager.getCachedDeviceManager().onBondingStateChanged(device, bondState);
|
mManager.getCachedDeviceManager().onBondingStateChanged(device, bondState);
|
||||||
if (bondState == BluetoothDevice.BOND_NOT_BONDED) {
|
if (bondState == BluetoothDevice.BOND_NOT_BONDED) {
|
||||||
int reason = intent.getIntExtra(BluetoothIntent.REASON, BluetoothError.ERROR);
|
int reason = intent.getIntExtra(BluetoothIntent.REASON, BluetoothDevice.ERROR);
|
||||||
if (reason == BluetoothDevice.UNBOND_REASON_AUTH_REJECTED ||
|
if (reason == BluetoothDevice.UNBOND_REASON_AUTH_REJECTED ||
|
||||||
reason == BluetoothDevice.UNBOND_REASON_AUTH_FAILED ||
|
reason == BluetoothDevice.UNBOND_REASON_AUTH_FAILED ||
|
||||||
reason == BluetoothDevice.UNBOND_REASON_REMOTE_DEVICE_DOWN) {
|
reason == BluetoothDevice.UNBOND_REASON_REMOTE_DEVICE_DOWN) {
|
||||||
|
@@ -20,7 +20,6 @@ import android.app.AlertDialog;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.bluetooth.BluetoothIntent;
|
import android.bluetooth.BluetoothIntent;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -50,8 +49,8 @@ public class BluetoothNamePreference extends EditTextPreference implements TextW
|
|||||||
if (action.equals(BluetoothIntent.NAME_CHANGED_ACTION)) {
|
if (action.equals(BluetoothIntent.NAME_CHANGED_ACTION)) {
|
||||||
setSummaryToName();
|
setSummaryToName();
|
||||||
} else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) &&
|
} else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) &&
|
||||||
(intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
(intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR) ==
|
||||||
BluetoothError.ERROR) == BluetoothAdapter.STATE_ON)) {
|
BluetoothAdapter.STATE_ON)) {
|
||||||
setSummaryToName();
|
setSummaryToName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,6 @@ import java.util.WeakHashMap;
|
|||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothIntent;
|
import android.bluetooth.BluetoothIntent;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -92,7 +91,7 @@ public class BluetoothSettings extends PreferenceActivity
|
|||||||
} else if (intent.getAction().equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)
|
} else if (intent.getAction().equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)
|
||||||
&& mScreenType == SCREEN_TYPE_DEVICEPICKER) {
|
&& mScreenType == SCREEN_TYPE_DEVICEPICKER) {
|
||||||
int bondState = intent
|
int bondState = intent
|
||||||
.getIntExtra(BluetoothIntent.BOND_STATE, BluetoothError.ERROR);
|
.getIntExtra(BluetoothIntent.BOND_STATE, BluetoothDevice.ERROR);
|
||||||
if (bondState == BluetoothDevice.BOND_BONDED) {
|
if (bondState == BluetoothDevice.BOND_BONDED) {
|
||||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothIntent.DEVICE);
|
BluetoothDevice device = intent.getParcelableExtra(BluetoothIntent.DEVICE);
|
||||||
sendDevicePickedIntent(device);
|
sendDevicePickedIntent(device);
|
||||||
|
@@ -20,7 +20,6 @@ import android.app.AlertDialog;
|
|||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -322,8 +321,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
||||||
int status = profileManager.getConnectionStatus(cachedDevice.mDevice);
|
int status = profileManager.getConnectionStatus(cachedDevice.mDevice);
|
||||||
if (SettingsBtStatus.isConnectionStatusConnected(status)) {
|
if (SettingsBtStatus.isConnectionStatusConnected(status)) {
|
||||||
if (profileManager.disconnect(cachedDevice.mDevice) ==
|
if (profileManager.disconnect(cachedDevice.mDevice)) {
|
||||||
BluetoothError.SUCCESS) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -408,7 +406,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
||||||
int status = profileManager.getConnectionStatus(cachedDevice.mDevice);
|
int status = profileManager.getConnectionStatus(cachedDevice.mDevice);
|
||||||
if (!SettingsBtStatus.isConnectionStatusConnected(status)) {
|
if (!SettingsBtStatus.isConnectionStatusConnected(status)) {
|
||||||
if (profileManager.connect(cachedDevice.mDevice) == BluetoothError.SUCCESS) {
|
if (profileManager.connect(cachedDevice.mDevice)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Log.i(TAG, "Failed to connect " + profile.toString() + " to " + cachedDevice.mName);
|
Log.i(TAG, "Failed to connect " + profile.toString() + " to " + cachedDevice.mName);
|
||||||
|
@@ -27,7 +27,6 @@ import android.app.AlertDialog;
|
|||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.bluetooth.BluetoothIntent;
|
import android.bluetooth.BluetoothIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -64,7 +63,7 @@ public class LocalBluetoothManager {
|
|||||||
private BluetoothEventRedirector mEventRedirector;
|
private BluetoothEventRedirector mEventRedirector;
|
||||||
private BluetoothA2dp mBluetoothA2dp;
|
private BluetoothA2dp mBluetoothA2dp;
|
||||||
|
|
||||||
private int mState = BluetoothError.ERROR;
|
private int mState = BluetoothAdapter.ERROR;
|
||||||
|
|
||||||
private List<Callback> mCallbacks = new ArrayList<Callback>();
|
private List<Callback> mCallbacks = new ArrayList<Callback>();
|
||||||
|
|
||||||
@@ -187,7 +186,7 @@ public class LocalBluetoothManager {
|
|||||||
|
|
||||||
public int getBluetoothState() {
|
public int getBluetoothState() {
|
||||||
|
|
||||||
if (mState == BluetoothError.ERROR) {
|
if (mState == BluetoothAdapter.ERROR) {
|
||||||
syncBluetoothState();
|
syncBluetoothState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +210,7 @@ public class LocalBluetoothManager {
|
|||||||
? BluetoothAdapter.STATE_ON
|
? BluetoothAdapter.STATE_ON
|
||||||
: BluetoothAdapter.STATE_OFF;
|
: BluetoothAdapter.STATE_OFF;
|
||||||
} else {
|
} else {
|
||||||
bluetoothState = BluetoothError.ERROR;
|
bluetoothState = BluetoothAdapter.ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
setBluetoothStateInt(bluetoothState);
|
setBluetoothStateInt(bluetoothState);
|
||||||
|
@@ -19,7 +19,6 @@ package com.android.settings.bluetooth;
|
|||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothError;
|
|
||||||
import android.bluetooth.BluetoothHeadset;
|
import android.bluetooth.BluetoothHeadset;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -102,9 +101,9 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
mLocalManager = localManager;
|
mLocalManager = localManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract int connect(BluetoothDevice device);
|
public abstract boolean connect(BluetoothDevice device);
|
||||||
|
|
||||||
public abstract int disconnect(BluetoothDevice device);
|
public abstract boolean disconnect(BluetoothDevice device);
|
||||||
|
|
||||||
public abstract int getConnectionStatus(BluetoothDevice device);
|
public abstract int getConnectionStatus(BluetoothDevice device);
|
||||||
|
|
||||||
@@ -145,7 +144,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int connect(BluetoothDevice device) {
|
public boolean connect(BluetoothDevice device) {
|
||||||
Set<BluetoothDevice> sinks = mService.getConnectedSinks();
|
Set<BluetoothDevice> sinks = mService.getConnectedSinks();
|
||||||
if (sinks != null) {
|
if (sinks != null) {
|
||||||
for (BluetoothDevice sink : sinks) {
|
for (BluetoothDevice sink : sinks) {
|
||||||
@@ -156,7 +155,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
return mService.disconnectSink(device);
|
return mService.disconnectSink(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,20 +239,19 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int connect(BluetoothDevice device) {
|
public boolean connect(BluetoothDevice device) {
|
||||||
// Since connectHeadset fails if already connected to a headset, we
|
// Since connectHeadset fails if already connected to a headset, we
|
||||||
// disconnect from any headset first
|
// disconnect from any headset first
|
||||||
mService.disconnectHeadset();
|
mService.disconnectHeadset();
|
||||||
return mService.connectHeadset(device)
|
return mService.connectHeadset(device);
|
||||||
? BluetoothError.SUCCESS : BluetoothError.ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (mService.getCurrentHeadset().equals(device)) {
|
if (mService.getCurrentHeadset().equals(device)) {
|
||||||
return mService.disconnectHeadset() ? BluetoothError.SUCCESS : BluetoothError.ERROR;
|
return mService.disconnectHeadset();
|
||||||
} else {
|
} else {
|
||||||
return BluetoothError.SUCCESS;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,13 +310,13 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int connect(BluetoothDevice device) {
|
public boolean connect(BluetoothDevice device) {
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user