Presence ScanRequest type def

PiperOrigin-RevId: 463703748
This commit is contained in:
hais
2022-07-27 16:17:46 -07:00
committed by Copybara-Service
parent a56d36f3a5
commit c7c698412c
3 changed files with 140 additions and 1 deletions
+3 -1
View File
@@ -48,17 +48,19 @@ cc_library(
"discovery_filter.h",
"discovery_options.h",
"listeners.h",
"power_mode.h",
"presence_action.h",
"presence_client.h",
"presence_device.h",
"presence_identity.h",
"presence_zone.h",
"scan_request.h",
"status.h",
],
deps = [
":credential",
"//internal/platform:base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:variant",
"@com_google_glog//:glog",
],
)
+35
View File
@@ -0,0 +1,35 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef THIRD_PARTY_NEARBY_PRESENCE_POWER_MODE_H_
#define THIRD_PARTY_NEARBY_PRESENCE_POWER_MODE_H_
namespace nearby {
namespace presence {
// High level concept of Power mode for Scan and Broadcast.
// More frequent, more power consumption, but less interval and latency.
// Native platforms would decide the specific interval based on their own
// configs.
enum class PowerMode {
kNoPower = 0,
kLowPower = 1,
kBalanced = 2,
kLowLatency = 3,
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_POWER_MODE_H_
+102
View File
@@ -0,0 +1,102 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef THIRD_PARTY_NEARBY_PRESENCE_SCAN_REQUEST_H_
#define THIRD_PARTY_NEARBY_PRESENCE_SCAN_REQUEST_H_
#include <string>
#include <vector>
#include "third_party/nearby/presence/credential.h"
#include "third_party/nearby/presence/data_element.h"
#include "third_party/nearby/presence/power_mode.h"
#include "third_party/nearby/presence/presence_identity.h"
namespace nearby {
namespace presence {
enum class ScanType {
kUnspecifiedScan = 0,
kFastPairScan = 1,
kPresenceScan = 2,
};
/**
* Filter for scanning a nearby presence device.
*/
struct ScanFilter {
ScanType scan_type;
};
/**
* Filter for scanning a nearby presence device.
* Supports Android U and above.
*/
struct PresenceScanFilter : public ScanFilter {
// A bundle of extended properties for matching.
std::vector<DataElement> extended_properties;
};
/**
* Used to support legacy Android T. Filter for scanning a nearby presence
* device.
*/
struct LegacyPresenceScanFilter : public ScanFilter {
// Minimum path loss threshold of the received scan result.
int path_loss_threshold;
// Android T needs clients to provide remote public credentials in scan
// requests.
std::vector<PublicCredential> remote_public_credentials;
// A list of presence actions for matching. Matching condition is met as
// long as theres one or more equal actions between Scan actions and
// Broadcast actions.
// Considered to use enum, and team agreed to use int to support potential
// un-reserved values. Already existing reserved interger values are defined
// in {@code ActionFactory}.
std::vector<int> actions;
// A bundle of extended properties for matching.
std::vector<DataElement> extended_properties;
};
/**
* An encapsulation of various parameters for requesting nearby scans.
*/
struct ScanRequest {
// Same as DeviceMetadata.account_name, to fetch private credential
// to broadcast.
std::string account_name;
// Used to specify which types of remote PublicCredential to use during the
// scan. If empty, use all available types of remote PublicCredential.
std::vector<PresenceIdentity::IdentityType> identity_types;
// For new Nearby SDK client (like chromeOs and Android U), use
// PresenceScanFilter; for Android T, use LegacyPresenceScanFilter.
std::vector<ScanFilter> scan_filters;
// Whether to use BLE in the scan.
bool use_ble;
ScanType scan_type;
PowerMode power_mode;
bool scan_only_when_screen_on;
};
} // namespace presence
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_PRESENCE_SCAN_REQUEST_H_