Commit Graph
410 Commits
Author SHA1 Message Date
Guogang Li 87e044fa89 Internal bug fix
PiperOrigin-RevId: 522474442
2023-04-06 17:03:47 -07:00
Guogang Li 5d4cf93aed Added thread protection to BLE V2 APIs
PiperOrigin-RevId: 522462123
2023-04-06 16:07:20 -07:00
Guogang Li 3432c829e1 Fixed crash during devices scanning
PiperOrigin-RevId: 522457603
2023-04-06 15:47:45 -07:00
Guogang Li fb4d42ad0d Harden thread pool
PiperOrigin-RevId: 522448312
2023-04-06 15:11:24 -07:00
Guogang Li 097ff07811 Added connect retry for Bluetooth
PiperOrigin-RevId: 522382120
2023-04-06 11:04:59 -07:00
Nick Bourdakos c919ed73a9 Update custom save path logic to include parent folder and prevent duplicate names from overwriting other files.
PiperOrigin-RevId: 522123924
2023-04-05 12:31:06 -07:00
hai007 c78bf2b209 Automated visibility attribute cleanup.
PiperOrigin-RevId: 522116588
2023-04-05 12:00:55 -07:00
hai007 c41fd2ed2a Disable broken tests.
PiperOrigin-RevId: 521949387
2023-04-04 21:31:49 -07:00
Janusz Sobczak 665b0b0e86 Add observer for pairing events.
Defines an observer for BT classic medium.
The observer is notified when a device is paired or unpaired.

PiperOrigin-RevId: 521917539
2023-04-04 18:13:07 -07:00
Nick Bourdakos 1d2b0272d3 Fix crash when closing Wi-Fi LAN server socket
PiperOrigin-RevId: 521883606
2023-04-04 15:36:43 -07:00
Nick Bourdakos f7edb0c858 Add Apple implementation for device info
PiperOrigin-RevId: 521834323
2023-04-04 12:27:43 -07:00
Guogang Li bda3a779bd Fixed the crash in Timer::Stop
PiperOrigin-RevId: 521822379
2023-04-04 11:41:44 -07:00
Guogang Li 3d752bc256 Added thread protection to BLE V2 APIs
PiperOrigin-RevId: 521774807
2023-04-04 08:49:44 -07:00
Nick Bourdakos d6f66237b0 Update Apple implementation to cancel the timer before calling the callback
This fixes a crash where the Timer is destroyed as soon as the callback is called, so Timer::Stop can't be safely called.

PiperOrigin-RevId: 521760888
2023-04-04 07:47:14 -07:00
Aaron Yu 977275f069 Add mutex guards for BLE publisher and watcher member variables to improve thread safety
PiperOrigin-RevId: 521611021
2023-04-03 17:49:25 -07:00
Hai Shang c312442f3d internal clean up
PiperOrigin-RevId: 521555239
2023-04-03 14:00:22 -07:00
Guogang Li d4169d0c94 Fixed an crash in Bluetooth adapter
PiperOrigin-RevId: 521164224
2023-04-01 11:32:39 -07:00
Qin Wang c1835fcfa1 Implement FastPairGattServiceClient for fast pair windows
PiperOrigin-RevId: 521005152
2023-03-31 13:52:34 -07:00
Guogang Li be99b60feb Applied platform thread to network lib
PiperOrigin-RevId: 520998502
2023-03-31 13:23:32 -07:00
hai007 17ce9c7dd2 Add the missing apple SDK framework dependencies.
PiperOrigin-RevId: 520936213
2023-03-31 09:07:14 -07:00
Guogang Li df9a87d524 internal cleanup
PiperOrigin-RevId: 520785471
2023-03-30 17:30:15 -07:00
Hai Shang 47b7a04939 minor clean up
PiperOrigin-RevId: 520734787
2023-03-30 13:56:57 -07:00
Guogang Li 8a66bff097 Made observer list thread safe
PiperOrigin-RevId: 520713657
2023-03-30 12:36:11 -07:00
Nick Bourdakos 14e7832be0 Internal change
PiperOrigin-RevId: 520638739
2023-03-30 12:34:53 -07:00
Janusz Sobczak c249c3079f Support fake clock in test environment
A synthetic clock helps testing (long) timeouts by allowing us to move the time
forward by an arbitrary amount.

PiperOrigin-RevId: 520407442
2023-03-29 12:19:28 -07:00
Guogang Li 5b94880740 Fixed some logic issues to handle BLE v2 advertisement
PiperOrigin-RevId: 520406643
2023-03-29 12:15:37 -07:00
Qin Wang a62000d3a8 Add g3 platform/medium_Environment for GattConnection
PiperOrigin-RevId: 520387265
2023-03-29 11:10:07 -07:00
Nick Bourdakos a933a91413 Internal Change
PiperOrigin-RevId: 520165614
2023-03-28 16:26:40 -07:00
Guogang Li b25314c34c Checked whether support BLE extended advertisement
PiperOrigin-RevId: 519848480
2023-03-27 15:41:38 -07:00
hai007 f2331cfb42 Clean up build file.
PiperOrigin-RevId: 518966242
2023-03-23 14:40:43 -07:00
Aaron Yu e232149008 Add catch(...) exceptions to catch unknown exceptions in NC bluetooth adapter
PiperOrigin-RevId: 518902703
2023-03-23 10:43:07 -07:00
Anay Wadhera 3f1b0c81e3 Weave port [2/n]: Introduce Weave packetizer implementation
PiperOrigin-RevId: 518881931
2023-03-23 09:30:55 -07:00
Janusz Sobczak adcb341190 Verify that IO on closed socket returns an error
The test implementation of BluetoothSocket::GetInputStream() would crash if
the socket was closed. That's not ideal because the caller can't verify if the
socket is open or closed.

New test verifies that GetOutputStream() and GetInputStream() always return a
valid reference.

PiperOrigin-RevId: 518722540
2023-03-22 18:04:12 -07:00
Janusz Sobczak 1a78b33a89 Add InputStream::ReadExactly
Read() can return fewer bytes than requested.
ReadExactly() will call Read() repeatedly until we
have read as many bytes as we need.

PiperOrigin-RevId: 518719418
2023-03-22 17:45:50 -07:00
Aaron Yu 59fc030843 Harden NC bluetooth adapter with try catch exceptions
PiperOrigin-RevId: 518664644
2023-03-22 13:55:27 -07:00
Nick Bourdakos cbf50a3d49 Add more visibilities
PiperOrigin-RevId: 518647351
2023-03-22 12:51:23 -07:00
Nick Bourdakos 0b3c759aa3 Remove unneeded WebRTC flags
PiperOrigin-RevId: 518629654
2023-03-22 11:44:12 -07:00
hai007 8b1791caab Automated visibility attribute cleanup.
PiperOrigin-RevId: 518628538
2023-03-22 11:39:32 -07:00
Nick Bourdakos ec025502dc Refactor WebRTC code to avoid use of select for stubs
PiperOrigin-RevId: 518491132
2023-03-22 00:25:54 -07:00
Guogang Li 78145f4433 Fixed crash during devices scanning
PiperOrigin-RevId: 518127975
2023-03-20 18:03:49 -07:00
hai007 d0b258971d Remove the coroutines workaround from Nearby and drop experimental/coroutines.
In Prod LLVM release branch 515643669.1 ( cl/517696539 ) the experimental coroutines implementation is dropped. The `experimental/coroutines` header is removed.

Nearby doesn't use coroutines, but it uses libraries that depend on the existence of coroutine function definitions. Specifically, WinRT needs certain coroutine function definitions in order to compile.

Ordinarily, WinRT relied on the coroutine function definitions provided in the MSVC STL' `experimental/coroutines` header. The introduction of libc++ complicated this dependency for Nearby, because libc++' `experimental/coroutines` header took the place of the MSVC version, and (correctly, for C++17) provided none of the coroutine function definitions.

To resolve these issues, we implemented a patch of WinRT. The patch provided placeholder definitions, which allowed WinRT to pass compilation. This patch was submitted in cl/495104919. The patch was necessary to enable the Nearby migration from MSVC STL to libc++.

--

The removal of `experimental/coroutines` from libc++ makes this patch unnecessary. However, the patch will not compile without libc++' `experimental/coroutines` header.

The presence of libc++' `experimental/coroutines` header had prevented the corresponding MSVC STL' header from defining the functions for which the patch makes placeholders. Without the libc++' `experimental/coroutines` header, the MSVC STL header is employed and makes these definitions. The patch then redefines these functions, which causes a compilation failure.

--

This CL makes two changes: 1) It eliminates the patch, and 2) It eliminates the libc++ `experimental/coroutines` file from the Lexan libc++ distribution. This allows Nearby to function identically before and after the release of Lexan 515643669.1.

This change prevents a break from occurring when Lexan 515643669.1 is released.

PiperOrigin-RevId: 518119913
2023-03-20 17:20:47 -07:00
Janusz Sobczak a7a3eb8a92 Use consistent return value in Pipe read.
Previously reading from an empty, closed Pipe returned:
* IO exception if there were no writes to the pipe,
* Empty byte array if there were writes to the pipe.
With this change, we return an empty byte array on both paths.

This also fixes a subtle race condition in the following flow:
1. Pipe is empty
2. Thread A is reading from the pipe (blocking call).
3. Thread B writes to the pipe and immediately closes it.
4. Thread A is unblocked and returns IO error. The data written by thread B is
   ignored!

The new test in bluetooth_classic_test triggered that defect consistently.

PiperOrigin-RevId: 518107700
2023-03-20 16:26:52 -07:00
Janusz Sobczak e202af3ccc Add value parameter to future listeners
Pass the Future result to listeners as a parameter.
This makes the AddListener() API a bit more convenient.

PiperOrigin-RevId: 518040156
2023-03-20 12:15:47 -07:00
Guogang Li 465a82dc1e Avoid task execution to crash thread pool
PiperOrigin-RevId: 517980691
2023-03-20 08:53:03 -07:00
Guogang Li 12156937ee Check device name before calling update callback
PiperOrigin-RevId: 517851883
2023-03-19 20:26:56 -07:00
Guogang Li 44e6ff7bb1 Avoid task execution to crash thread pool
PiperOrigin-RevId: 517558076
2023-03-17 18:58:28 -07:00
Guogang Li 700d5c9dcc Fixed crash bug in BluetoothAdapter
PiperOrigin-RevId: 517556635
2023-03-17 18:44:51 -07:00
Anay Wadhera 69d2098ecb Weave port [1/n]: Introduce Weave packet implementation
PiperOrigin-RevId: 517526002
2023-03-17 15:44:09 -07:00
Janusz Sobczak 8f887064ec Fix dead-lock during executor shutdown
The flow below caused a dead-lock:
1. A lengthy task A is running on an executor.
2. Executor is destructed, or `Shutdown()` on another thread. The call blocks
   waiting for A to complete.
3. Task A executes another task B on the executor. The call blocks forever.

PiperOrigin-RevId: 517495348
2023-03-17 13:34:57 -07:00
Qin Wang 86ca85b85a Migrate fake functions to third_party/nearby to help unit test
PiperOrigin-RevId: 517433481
2023-03-17 09:34:58 -07:00