Merge "BluetoothManager: Continue when BLE not supported"
This commit is contained in:
@@ -762,26 +762,16 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action taken when GattService is turned on
|
* Call IBluetooth.onLeServiceUp() to continue if Bluetooth should be on.
|
||||||
*/
|
*/
|
||||||
private void onBluetoothGattServiceUp() {
|
private void continueFromBleOnState() {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "BluetoothGatt Service is Up");
|
Slog.d(TAG, "continueFromBleOnState()");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
mBluetoothLock.readLock().lock();
|
mBluetoothLock.readLock().lock();
|
||||||
if (mBluetooth == null) {
|
if (mBluetooth == null) {
|
||||||
if (DBG) {
|
Slog.e(TAG, "onBluetoothServiceUp: mBluetooth is null!");
|
||||||
Slog.w(TAG, "onBluetoothServiceUp: mBluetooth is null!");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int st = mBluetooth.getState();
|
|
||||||
if (st != BluetoothAdapter.STATE_BLE_ON) {
|
|
||||||
if (DBG) {
|
|
||||||
Slog.v(TAG, "onBluetoothServiceUp: state isn't BLE_ON: "
|
|
||||||
+ BluetoothAdapter.nameForState(st));
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isBluetoothPersistedStateOnBluetooth() || !isBleAppPresent()) {
|
if (isBluetoothPersistedStateOnBluetooth() || !isBleAppPresent()) {
|
||||||
@@ -1613,7 +1603,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
if (msg.arg1 == SERVICE_IBLUETOOTHGATT) {
|
if (msg.arg1 == SERVICE_IBLUETOOTHGATT) {
|
||||||
mBluetoothGatt =
|
mBluetoothGatt =
|
||||||
IBluetoothGatt.Stub.asInterface(Binder.allowBlocking(service));
|
IBluetoothGatt.Stub.asInterface(Binder.allowBlocking(service));
|
||||||
onBluetoothGattServiceUp();
|
continueFromBleOnState();
|
||||||
break;
|
break;
|
||||||
} // else must be SERVICE_IBLUETOOTH
|
} // else must be SERVICE_IBLUETOOTH
|
||||||
|
|
||||||
@@ -2030,21 +2020,16 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "Bluetooth is in LE only mode");
|
Slog.d(TAG, "Bluetooth is in LE only mode");
|
||||||
}
|
}
|
||||||
if (mBluetoothGatt != null) {
|
if (mBluetoothGatt != null || !mContext.getPackageManager()
|
||||||
if (DBG) {
|
.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
|
||||||
Slog.d(TAG, "Calling BluetoothGattServiceUp");
|
continueFromBleOnState();
|
||||||
}
|
|
||||||
onBluetoothGattServiceUp();
|
|
||||||
} else {
|
} else {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Slog.d(TAG, "Binding Bluetooth GATT service");
|
Slog.d(TAG, "Binding Bluetooth GATT service");
|
||||||
}
|
}
|
||||||
if (mContext.getPackageManager()
|
Intent i = new Intent(IBluetoothGatt.class.getName());
|
||||||
.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
|
doBind(i, mConnection, Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT,
|
||||||
Intent i = new Intent(IBluetoothGatt.class.getName());
|
UserHandle.CURRENT);
|
||||||
doBind(i, mConnection, Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT,
|
|
||||||
UserHandle.CURRENT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sendBleStateChanged(prevState, newState);
|
sendBleStateChanged(prevState, newState);
|
||||||
//Don't broadcase this as std intent
|
//Don't broadcase this as std intent
|
||||||
|
|||||||
Reference in New Issue
Block a user