Merge "Move advetise clean up to callback code. fixes b/13289050"
This commit is contained in:
@@ -590,7 +590,6 @@ public final class BluetoothAdapter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mAdvertisingGattCallback.stopAdvertising();
|
mAdvertisingGattCallback.stopAdvertising();
|
||||||
mAdvertisingGattCallback = null;
|
|
||||||
return true;
|
return true;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
@@ -1794,15 +1793,12 @@ public final class BluetoothAdapter {
|
|||||||
try {
|
try {
|
||||||
IBluetoothGatt iGatt = adapter.getBluetoothManager().getBluetoothGatt();
|
IBluetoothGatt iGatt = adapter.getBluetoothManager().getBluetoothGatt();
|
||||||
iGatt.stopAdvertising();
|
iGatt.stopAdvertising();
|
||||||
Log.d(TAG, "unregistering client " + mLeHandle);
|
|
||||||
iGatt.unregisterClient(mLeHandle);
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Failed to stop advertising and unregister" + e);
|
Log.e(TAG, "Failed to stop advertising" + e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "stopAdvertising, BluetoothAdapter is null");
|
Log.e(TAG, "stopAdvertising, BluetoothAdapter is null");
|
||||||
}
|
}
|
||||||
mLeHandle = -1;
|
|
||||||
notifyAll();
|
notifyAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1992,6 +1988,26 @@ public final class BluetoothAdapter {
|
|||||||
if (advertiseState == STATE_ADVERTISE_STARTED) {
|
if (advertiseState == STATE_ADVERTISE_STARTED) {
|
||||||
mAdvertiseCallback.onAdvertiseStart(status);
|
mAdvertiseCallback.onAdvertiseStart(status);
|
||||||
} else {
|
} else {
|
||||||
|
synchronized (this) {
|
||||||
|
if (status == ADVERTISE_CALLBACK_SUCCESS) {
|
||||||
|
BluetoothAdapter adapter = mBluetoothAdapter.get();
|
||||||
|
if (adapter != null) {
|
||||||
|
try {
|
||||||
|
IBluetoothGatt iGatt =
|
||||||
|
adapter.getBluetoothManager().getBluetoothGatt();
|
||||||
|
Log.d(TAG, "unregistering client " + mLeHandle);
|
||||||
|
iGatt.unregisterClient(mLeHandle);
|
||||||
|
// Reset advertise app handle.
|
||||||
|
mLeHandle = -1;
|
||||||
|
adapter.mAdvertisingGattCallback = null;
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "Failed to unregister client" + e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "cannot unregister client, BluetoothAdapter is null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
mAdvertiseCallback.onAdvertiseStop(status);
|
mAdvertiseCallback.onAdvertiseStop(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user