Commit Graph
662 Commits
Author SHA1 Message Date
hai007 a2d018cd87 Add nullability annotation
PiperOrigin-RevId: 637062647
2024-05-24 16:19:04 -07:00
Juliet Levesque 84bb5700c4 [Nearby Presence] Check IsValid() before accessing impl_
Adding a check to `IsInvalid()` before accessing `impl_` in
`Blev2Medium::IsExtendedAdvertisementsAvailable()` to prevent a crash when
`impl_` is nullptr (which occurs when BleV2 is disabled).

PiperOrigin-RevId: 635854690
2024-05-21 10:38:27 -07:00
Eiden Kim dca2997f5d Added more checks to file path validation.
PiperOrigin-RevId: 635580793
2024-05-20 15:03:50 -07:00
Eiden Kim b224f8660c Check illegal characters from the file and parent folder name
PiperOrigin-RevId: 634941778
2024-05-17 18:46:26 -07:00
Eiden Kim 33d66fd169 Check illegal characters from the file and parent folder name
PiperOrigin-RevId: 634598623
2024-05-16 18:54:45 -07:00
Anay Wadhera 4aa73df657 Internal changes for stub impl
PiperOrigin-RevId: 634082976
2024-05-15 14:49:33 -07:00
Anay Wadhera fcc08df58b internal change
PiperOrigin-RevId: 634077236
2024-05-15 14:31:46 -07:00
hai007 556a026a6e Automated Code Change
PiperOrigin-RevId: 633055418
2024-05-12 18:49:35 -07:00
hai007 7c72774167 Multiplex implementation - Create Multiplex Socket
PiperOrigin-RevId: 632628955
2024-05-10 16:11:26 -07:00
Anay Wadhera f26d25ed01 Provide a platform abstraction for RandBytes instead of swapping headers
The `RandBytes` functions were being placed in the `crypto` namespace,
which collides with Chromium's namespace of the same name. Within,
`RandBytes` was defined with almost-the-same API. Then in Chromium
builds, the Chromium header would be used instead (though somewhat
inconsistently).

This creates a lot of pain for Chromium development as there's a
third-party repository directly depending on headers from Chromium's
source tree, and is against the third-party policies for that reason.
There are a number of other headers that mirror Chromium and are
swapped out in the Chromium build that will cause similar pain, such as:
```
include "crypto/aead.h"
include "crypto/ec_private_key.h"
include "crypto/hkdf.h"
```

This CL provides a template for how to get rid of these header swaps and
give a platform abstraction in nearby instead.

We provide a platform abstraction in `platform/crypto.h` (really in
`platform/implementation/crypto.h`) which is implemented in
`platform/implementation/shared/crypto.cc`. However that implementation
is removed by `#ifdef` when in the Chromium build.

Then, in the Chromium repo, we will add (separately) an implementation
of the same abstraction in `//third_party/nearby/platform_impl` with GN
rules to include it in the build. It will replace the implementation
from the nearby repo.

Copybara import of the project:

--
6ca8099 by danakj <danakj@chromium.org>:

Provide a platform abstraction for RandBytes instead of swapping headers

The `RandBytes` functions were being placed in the `crypto` namespace,
which collides with Chromium's namespace of the same name. Within,
`RandBytes` was defined with almost-the-same API. Then in Chromium
builds, the Chromium header would be used instead (though somewhat
inconsistently).

This creates a lot of pain for Chromium development as there's a
third-party repository directly depending on headers from Chromium's
source tree, and is against the third-party policies for that reason.
There are a number of other headers that mirror Chromium and are
swapped out in the Chromium build that will cause similar pain, such as:
```
include "crypto/aead.h"
include "crypto/ec_private_key.h"
include "crypto/hkdf.h"
```

This CL provides a template for how to get rid of these header swaps and
give a platform abstraction in nearby instead.

We provide a platform abstraction in `platform/crypto.h` (really in
`platform/implementation/crypto.h`) which is implemented in
`platform/implementation/shared/crypto.cc`. However that implementation
is removed by `#ifdef` when in the Chromium build.

Then, in the Chromium repo, we will add (separately) an implementation
of the same abstraction in `//third_party/nearby/platform_impl` with GN
rules to include it in the build. It will replace the implementation
from the nearby repo.

--
9c2654b by danakj <danakj@chromium.org>:

Remove CryptoSpan, use absl::Span

The header swapping of Chromium crypto libraries is
problematic, but absl::Span will convert to base::span
so there's no need for the typedef even without
removing the header swapping yet.

--
df1135d by danakj <danakj@chromium.org>:

Add missing files

--
ab18a15 by danakj <danakj@chromium.org>:

Remove the random_unittest.cc from Swift build

The file moved, so the Swift package needs its path
updated.

--
2038f78 by danakj <danakj@chromium.org>:

Combine crypto unittests into crypto_test.cc

--
f7ad176 by danakj <danakj@chromium.org>:

Add stdint and stddef includes for uint8_t and size_t

--
9f04590 by danakj <danakj@chromium.org>:

Mark the shared crypto implementation compatable_with non_prod

--
18eeafd by danakj <danakj@chromium.org>:

Add IWYU pragma for crypto implementation

PiperOrigin-RevId: 632150866
2024-05-09 08:02:50 -07:00
Ryan Hansberry cc84b6f4a4 Make credential refill asynchronous
Fixes a ChromeOS-deadlock during credential refill. The
previous logic blocked the IO thread that ChromeOS is using
to listen for responses from its CredentialStorage layer,
thus preventing it from signaling the latch.

Given that CheckCredentialsAndRefillIfNeeded is meant to
be async (given its continuation-passing style), this CL
avoids any thread trickiness by removing any latch-waiting
within the function. The nice side-effect of this is breaking
up the function into 3 smaller functions, which should
hopefully make it a bit more readable.

//.../g3/credential_storage_impl.cc has its mutex locks
removed -- they otherwise cause deadlocks, and are now
unnecessary.

This CL introduces a CHECK_EQ to ensure that the number of
remaining valid (not-expired) credentials is equal across the
shared and local list. This actually exposed a bug in the
credential_manager_impl_test.cc -- the test was only expiring
a public credential, and not its corresponding private credential.
Thus, the test is also updated in this CL to correctly mark
the first credential of the shared and local list as expired.

PiperOrigin-RevId: 631822135
2024-05-08 09:14:53 -07:00
Hai Shang 17df967296 replace secrect_id to id inside presence credential manager
PiperOrigin-RevId: 630558485
2024-05-03 19:28:48 -07:00
hai007 bba1ca540f Remove provisioned identity type from proto
PiperOrigin-RevId: 629178167
2024-04-29 13:59:55 -07:00
hai007 0b04994f71 Update identity type name
PiperOrigin-RevId: 629163344
2024-04-29 13:12:45 -07:00
hai007 a1b80ff649 Update identity type name
PiperOrigin-RevId: 628545355
2024-04-26 16:57:25 -07:00
hai007 54eff829b5 Update identity type name
PiperOrigin-RevId: 628513553
2024-04-26 14:40:17 -07:00
Francis Tsui 159ca34072 Add Shutdown method to TaskRunner.
PiperOrigin-RevId: 628448253
2024-04-26 10:44:21 -07:00
Guogang Li c9c8544669 Added a new Uuid constructor from UUID string
PiperOrigin-RevId: 628288959
2024-04-25 21:48:39 -07:00
hai007 19adc300a0 Automated Code Change
PiperOrigin-RevId: 627267684
2024-04-22 22:39:50 -07:00
Ryan Hansberry 5c933e5b9c [Device Provider] Add FakeDeviceProvider for testing
Create a FakeDeviceProvider class which will be used in testing for NearbyPresence
and NearbyConnections. To assist with testing PresenceService will store a NearbyDeviceProvider base class instead of the implementation specific PresenceDeviceProvider.

PiperOrigin-RevId: 625845617
2024-04-17 16:47:31 -07:00
hai007 6fc1559d23 Automated Code Change
PiperOrigin-RevId: 624435924
2024-04-13 02:06:34 -07:00
Daniel Classon 05dac6b184 [Nearby Connections] Rename async scanning flag
Renames the enable_ble_v2_async_scanning_advertising flag to just
enable_ble_v2_async_scanning, reflecting that scanning/advertising
can be enabled independently. Work required to add async
advertising is tracked in b/333408829.

PiperOrigin-RevId: 624254277
2024-04-12 12:15:21 -07:00
Edwin Wu 78505e91f7 Add the privacy manifests for swift NC-SDK.
PiperOrigin-RevId: 623676227
2024-04-10 19:19:11 -07:00
hai007 1e1d841965 Multiplex implementation - Create Virtual Output Stream
PiperOrigin-RevId: 623540454
2024-04-10 10:44:50 -07:00
Nick Bourdakos a08a42077c PR #2404: Add license header to all source files
Imported from GitHub PR https://github.com/google/nearby/pull/2404

Copybara import of the project:

--
a6fbb3c396321c0b9012b787323f5f2ff652fd8f by Nick Bourdakos <bourdakos1@gmail.com>:

Add license header to all source files

Merging this change closes #2404

PiperOrigin-RevId: 623540004
2024-04-10 10:40:38 -07:00
hai007 c198af1495 Automated Code Change
PiperOrigin-RevId: 623376075
2024-04-09 22:14:22 -07:00
Francis Tsui 8d41593056 Internal changes.
PiperOrigin-RevId: 623002360
2024-04-08 17:56:34 -07:00
Francis Tsui d69bd78d13 Fix deadlock during log rotations.
PiperOrigin-RevId: 622916139
2024-04-08 12:10:26 -07:00
hai007 b9184d39ec Automated Code Change
PiperOrigin-RevId: 622382640
2024-04-05 23:43:26 -07:00
hai007 2a56254756 Automated Code Change
PiperOrigin-RevId: 621908243
2024-04-04 10:52:30 -07:00
Francis Tsui d33c8c6aef Fix preference file loading bug.
PiperOrigin-RevId: 621604205
2024-04-03 12:27:51 -07:00
hai007 80570e55b0 Automated Code Change
PiperOrigin-RevId: 620702020
2024-03-31 16:16:32 -07:00
Francis Tsui 1e08b2d886 Fixed remaining filesystem calls that throws exceptions.
PiperOrigin-RevId: 620379472
2024-03-29 17:33:25 -07:00
Hai Shang 6162fb5f80 add legacy_device_discovered_cb to DiscoveredPeripheralCallback
PiperOrigin-RevId: 619702145
2024-03-27 17:45:37 -07:00
Guogang Li 387a51b260 internal update
PiperOrigin-RevId: 619595164
2024-03-27 11:25:55 -07:00
Francis Tsui 0c086a3c93 Minor fixes to reduce copying.
PiperOrigin-RevId: 616927443
2024-03-18 13:22:56 -07:00
Hai Shang 30c9c55d3b Initial Async version of StartAdvertising for windows.
PiperOrigin-RevId: 616915567
2024-03-18 12:43:12 -07:00
Francis Tsui 33e682f244 Bypass GN check of absl/log include.
PiperOrigin-RevId: 615954726
2024-03-14 17:29:31 -07:00
Francis Tsui a082f36021 Switch glog to absl::log.
PiperOrigin-RevId: 615535748
2024-03-13 14:03:23 -07:00
hai007 cf2a1eb0b1 Internal change
PiperOrigin-RevId: 613133183
2024-03-06 10:21:45 -08:00
Copybara-Service ee404cb766 Merge pull request #2307 from ChenWangG:patch-1
PiperOrigin-RevId: 612604370
2024-03-04 15:42:43 -08:00
Daniel Classon f09368247b [Nearby Connections] Use async StartScanning when flag enabled
Creates the feature flag `enable_ble_v2_async_scanning_advertising` which
enables/disables the use of the async StartScanning, StopScanning,
StartAdvertising, StopAdvertising, etc methods over the soon-to-be deprecated
synchronous versions of those methods. Opted for feature flag over NearbyFlag,
as ChromeOS is the only current consumer and doesn't use Mendel.

Also sets the feature flag to enabled in the ServiceControllerRouter, which
is where ChromeOS sets NC feature flags at startup.

This CL also fully links up the asynchronous Scanning methods. Advertising
will be addressed in a follow up CL.

PiperOrigin-RevId: 608158273
2024-02-18 12:59:02 -08:00
Hai Shang f8c907a120 internal cleanup
PiperOrigin-RevId: 605780857
2024-02-09 18:13:40 -08:00
Hai Shang 17a71c8b7e Internal cleanup
PiperOrigin-RevId: 604442644
2024-02-05 15:00:32 -08:00
Hai Shang 9896e327c0 internal clean
PiperOrigin-RevId: 604358478
2024-02-05 10:23:25 -08:00
Juliet Levesque 6b2f7fa94e [Nearby Presence] Fetch and select correct local credentials
Fetch the local credentials and select the correct local credential by verifying the validity of the time. This CL will be followed by
using the selected local credential for authentication. See go/cros-nearby-presence-np-nc-authentication  for details.

PiperOrigin-RevId: 603772266
2024-02-02 17:23:41 -08:00
hai007 f112d9ff71 Change code to follow payload ack send/receive frame format change.
PiperOrigin-RevId: 601486151
2024-01-25 10:17:23 -08:00
Guogang Li caa82a41d8 Added flag control to Bluetooth update
PiperOrigin-RevId: 599538193
2024-01-18 09:54:54 -08:00
hai007 744219b1e6 Fix Intel PIE bugs and update test code
PiperOrigin-RevId: 598965857
2024-01-16 14:54:48 -08:00
Guogang Li e1f7044f28 Fixed the bug to get file size
PiperOrigin-RevId: 597266370
2024-01-10 09:05:15 -08:00