Fixes an issue where if a characteristic is created and then updated with a non-nil value, and a new characteristic under the same service is added, then when the service is re-added the old characteristic will be permanently cached and the dynamic reads will stop working.
This also eliminates the issue when characteristics are created concurrently, since service additions are batched, if the service addition fails then only one of the characteristics will know that it failed to get added.
This change also introduces the nuance of "success" does not mean the CoreBluetooth method has completed successfully, but instead means that the intended state has been recorded and the class will do its best to maintain that state. For example, a successful "start advertising" call means that we have the advertisement cached and we will start advertising as soon as we can (like BT transitions from off to on) and will do our best to keep advertising (like BT transitions from on to off to on again).
PiperOrigin-RevId: 551660634
All tasks in base_pcp_handler must complete before
p2p_cluster_pcp_handler is destroyed to prevent use-after-free errors.
Added a couple of missing StopDiscovery calls.
PiperOrigin-RevId: 547931350
Some of the tests are flaky.
Significantly increased timeouts will give us confidence that
tests are failing due to a defect and not due to a test taking a little
bit more time than usual.
PiperOrigin-RevId: 547819011
ExceptionOr<T>::ok() returns true if the value is set. This can be misleading
for boolean types.
ExceptionOr<bool> result = SomeFunction();
if (result.ok()) {
if (result.result() {
// Case 1: SomeFunction returned true
} else {
// Case 2: SomeFunction returned false
} else {
// Case 3: SomeFunction returned an exception
}
It's easy to overlook case 2.
The specialized ExceptionOr<bool>::ok() returns false in Case 2, which allows
us to write:
if (result) {
// SomeFunction returned true
} else {
// SomeFunction returned false or an exception
// result.GetException() can be used if we need to handle different exceptions
// differenty
}
PiperOrigin-RevId: 544715641
Re-enables Cancellation Flags once fixes for crashes caused by destroying the cancellation flags that are being consumed by other classes have landed.
PiperOrigin-RevId: 543857192
Suspect the file was corrupted when sending to receiver side. Check if it is good first, then peek. By this way, the crash maybe avoid. For further protection, add exception protection here.
PiperOrigin-RevId: 542884209