mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
added ftxui dependency
This commit is contained in:
@@ -11,6 +11,10 @@ bazel_dep(name = "googletest", version = "1.17.0.bcr.2", repo_name = "com_google
|
||||
bazel_dep(name = "boringssl", version = "0.20251124.0")
|
||||
bazel_dep(name = "rules_foreign_cc", version = "0.15.1")
|
||||
|
||||
# for linux TUI
|
||||
# Should update to 7.0.0
|
||||
bazel_dep(name = "ftxui", version = "6.1.9")
|
||||
|
||||
|
||||
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
|
||||
|
||||
|
||||
Generated
+5
-3
@@ -63,6 +63,8 @@
|
||||
"https://bcr.bazel.build/modules/boringssl/0.20251124.0/source.json": "2f325a76db6c6e14c4db923a26aa9a4bfbbd03e61b9256311f460c18bfba6013",
|
||||
"https://bcr.bazel.build/modules/buildozer/8.5.1/MODULE.bazel": "a35d9561b3fc5b18797c330793e99e3b834a473d5fbd3d7d7634aafc9bdb6f8f",
|
||||
"https://bcr.bazel.build/modules/buildozer/8.5.1/source.json": "e3386e6ff4529f2442800dee47ad28d3e6487f36a1f75ae39ae56c70f0cd2fbd",
|
||||
"https://bcr.bazel.build/modules/ftxui/6.1.9/MODULE.bazel": "cc9326c084f535dab294bc7aaea0be08ceedd7623c421e09e7ab16f921f4fcb7",
|
||||
"https://bcr.bazel.build/modules/ftxui/6.1.9/source.json": "401772aaf4b1dc988ffe03a8280e94927bd4e318b98724ba309f41000c41283e",
|
||||
"https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb",
|
||||
"https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4",
|
||||
"https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6",
|
||||
@@ -152,8 +154,8 @@
|
||||
"https://bcr.bazel.build/modules/rules_java/8.3.2/MODULE.bazel": "7336d5511ad5af0b8615fdc7477535a2e4e723a357b6713af439fe8cf0195017",
|
||||
"https://bcr.bazel.build/modules/rules_java/8.5.1/MODULE.bazel": "d8a9e38cc5228881f7055a6079f6f7821a073df3744d441978e7a43e20226939",
|
||||
"https://bcr.bazel.build/modules/rules_java/8.6.1/MODULE.bazel": "f4808e2ab5b0197f094cabce9f4b006a27766beb6a9975931da07099560ca9c2",
|
||||
"https://bcr.bazel.build/modules/rules_java/9.1.0/MODULE.bazel": "ee63f27e36a3fada80342869361182f120a9819c74320e8e65b1e04ba0cd7a9d",
|
||||
"https://bcr.bazel.build/modules/rules_java/9.1.0/source.json": "da589573c1dee2c9ac4a568b301269a2e8191110ff0345c1a959fa7ea6c4dfd6",
|
||||
"https://bcr.bazel.build/modules/rules_java/9.0.3/MODULE.bazel": "1f98ed015f7e744a745e0df6e898a7c5e83562d6b759dfd475c76456dda5ccea",
|
||||
"https://bcr.bazel.build/modules/rules_java/9.0.3/source.json": "b038c0c07e12e658135bbc32cc1a2ded6e33785105c9d41958014c592de4593e",
|
||||
"https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7",
|
||||
"https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909",
|
||||
"https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036",
|
||||
@@ -220,7 +222,7 @@
|
||||
"moduleExtensions": {
|
||||
"@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "Ga4z8lQy1YQ5rAMy+dOl0dqcCEBnYNCXku8x3YQmDZI=",
|
||||
"bzlTransitiveDigest": "ABI1D/sbS1ovwaW/kHDoj8nnXjQ0oKU9fzmzEG4iT8o=",
|
||||
"usagesDigest": "QI2z8ZUR+mqtbwsf2fLqYdJAkPOHdOV+tF2yVAUgRzw=",
|
||||
"recordedInputs": [
|
||||
"REPO_MAPPING:rules_kotlin+,bazel_tools bazel_tools"
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ cc_library(
|
||||
"platform/platform_util.cc",
|
||||
"platform/platform_util.h",
|
||||
],
|
||||
hdrs = ["platform/linux_sharing_platform.h"],
|
||||
hdrs = ["platform/linux_sharing_platform.h", "nearby_noop_analytics_recorder.h"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":fast_init",
|
||||
|
||||
@@ -6,47 +6,64 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
constexpr std::string_view sock_path = "/tmp/nearby_sharing.sock";
|
||||
|
||||
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/flags/nearby_flags.h"
|
||||
#include "sharing/advertisement.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/file_attachment.h"
|
||||
#include "sharing/linux/platform/linux_sharing_platform.h"
|
||||
#include "sharing/linux/nearby_noop_analytics_recorder.h"
|
||||
#include "sharing/flags/generated/nearby_sharing_feature_flags.h"
|
||||
#include "sharing/nearby_sharing_service.h"
|
||||
#include "sharing/nearby_sharing_service_factory.h"
|
||||
#include "sharing/nearby_sharing_settings.h"
|
||||
#include "sharing/share_target.h"
|
||||
#include "sharing/share_target_discovered_callback.h"
|
||||
#include "sharing/transfer_metadata.h"
|
||||
#include "sharing/transfer_update_callback.h"
|
||||
#include "sharing/proto/enums.pb.h"
|
||||
|
||||
|
||||
int main() {
|
||||
// should always be waiting on the socket for new connections
|
||||
int retries = 3;
|
||||
while (retries >= 0) {
|
||||
int server_fd;
|
||||
struct sockaddr_un addr;
|
||||
namespace nearby::sharing::linux {
|
||||
|
||||
server_fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (server_fd == -1) {
|
||||
retries--;
|
||||
continue;
|
||||
}
|
||||
class DiscoveryCallback final : public ShareTargetDiscoveredCallback {
|
||||
public:
|
||||
explicit DiscoveryCallback() {}
|
||||
|
||||
// removes old socket
|
||||
unlink(sock_path.data());
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
strncpy(addr.sun_path, sock_path.data(), sizeof(addr.sun_path) - 1);
|
||||
|
||||
if (bind(server_fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
|
||||
close(server_fd);
|
||||
retries--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (listen(server_fd, 10) == -1) {
|
||||
close(server_fd);
|
||||
retries--;
|
||||
continue;
|
||||
}
|
||||
socklen_t addr_len = sizeof(addr);
|
||||
|
||||
// blocks till connection is present
|
||||
if (accept(server_fd, (struct sockaddr*)&addr, &addr_len)) {
|
||||
close(server_fd);
|
||||
retries--;
|
||||
continue;
|
||||
void OnShareTargetDiscovered(const ShareTarget& share_target) override {
|
||||
std::cout << "discovered target=\"" << share_target.device_name
|
||||
<< "\" id=" << share_target.id << std::endl;
|
||||
if (share_target.receive_disabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void OnShareTargetLost(const ShareTarget& share_target) override {
|
||||
std::cout << "lost target=\"" << share_target.device_name
|
||||
<< "\" id=" << share_target.id << std::endl;
|
||||
}
|
||||
|
||||
void OnShareTargetUpdated(const ShareTarget& share_target) override {
|
||||
std::cout << "updated target=\"" << share_target.device_name
|
||||
<< "\" id=" << share_target.id << std::endl;
|
||||
OnShareTargetDiscovered(share_target);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
int main() {
|
||||
auto analytics_recorder = nearby::sharing::linux::NoOpAnalyticsRecorder();
|
||||
auto linux_platform = nearby::sharing::linux::LinuxSharingPlatform("LinuxShare");
|
||||
auto service_ = nearby::sharing::NearbySharingServiceFactory::GetInstance()->CreateSharingService(
|
||||
linux_platform, &analytics_recorder, /*event_logger=*/nullptr,
|
||||
/*supports_file_sync=*/false);
|
||||
if (service_ == nullptr) {
|
||||
std::cerr << "failed to create NearbySharingService" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DELEGATE_SCRIPT="${SCRIPT_DIR}/install_nearby_sharing_service.sh"
|
||||
|
||||
if [[ ! -x "${DELEGATE_SCRIPT}" ]]; then
|
||||
echo "Missing installer: ${DELEGATE_SCRIPT}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat <<'MSG'
|
||||
install_nearby_connections_service.sh is deprecated.
|
||||
Installing Nearby Sharing API artifacts instead.
|
||||
MSG
|
||||
|
||||
exec "${DELEGATE_SCRIPT}" "$@"
|
||||
@@ -1,157 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
TARGET="//sharing/linux:nearby_sharing_api_shared"
|
||||
HEADER_SRC="sharing/linux/nearby_sharing_api.h"
|
||||
BAZEL_CMD="${BAZEL:-bazel}"
|
||||
PREFIX="/usr/local"
|
||||
LIBDIR=""
|
||||
INCLUDEDIR=""
|
||||
SKIP_BUILD=0
|
||||
NEEDS_ELEVATION=0
|
||||
INSTALL_PREFIX=()
|
||||
|
||||
usage() {
|
||||
cat <<USAGE
|
||||
Usage: $0 [options]
|
||||
|
||||
Builds and installs the Nearby Sharing shared library and public header.
|
||||
|
||||
Options:
|
||||
--prefix DIR Install prefix (default: /usr/local)
|
||||
--libdir DIR Library directory (default: <prefix>/lib)
|
||||
--includedir DIR Include root directory (default: <prefix>/include)
|
||||
--bazel CMD Bazel command (default: bazel or env BAZEL)
|
||||
--skip-build Skip bazel build step and only install from bazel-bin
|
||||
-h, --help Show this help
|
||||
|
||||
Examples:
|
||||
$0
|
||||
sudo $0
|
||||
sudo $0 --prefix /usr
|
||||
sudo $0 --bazel /usr/bin/bazel
|
||||
USAGE
|
||||
}
|
||||
|
||||
run_bazel() {
|
||||
if [[ "$(id -u)" -eq 0 && -n "${SUDO_USER:-}" ]]; then
|
||||
local caller_home
|
||||
caller_home="$(getent passwd "$SUDO_USER" | cut -d: -f6)"
|
||||
if [[ -z "$caller_home" ]]; then
|
||||
echo "Failed to resolve home directory for SUDO_USER=$SUDO_USER" >&2
|
||||
exit 1
|
||||
fi
|
||||
sudo -u "$SUDO_USER" -H env \
|
||||
HOME="$caller_home" \
|
||||
BAZELISK_HOME="${BAZELISK_HOME:-$caller_home/.cache/bazelisk}" \
|
||||
"$BAZEL_CMD" "$@"
|
||||
else
|
||||
"$BAZEL_CMD" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
nearest_existing_parent() {
|
||||
local p="$1"
|
||||
while [[ ! -e "$p" ]]; do
|
||||
p="$(dirname "$p")"
|
||||
done
|
||||
printf '%s\n' "$p"
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--prefix)
|
||||
PREFIX="$2"
|
||||
shift 2
|
||||
;;
|
||||
--libdir)
|
||||
LIBDIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
--includedir)
|
||||
INCLUDEDIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
--bazel)
|
||||
BAZEL_CMD="$2"
|
||||
shift 2
|
||||
;;
|
||||
--skip-build)
|
||||
SKIP_BUILD=1
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$LIBDIR" ]]; then
|
||||
LIBDIR="${PREFIX}/lib"
|
||||
fi
|
||||
|
||||
if [[ -z "$INCLUDEDIR" ]]; then
|
||||
INCLUDEDIR="${PREFIX}/include"
|
||||
fi
|
||||
|
||||
LIB_PARENT="$(nearest_existing_parent "$LIBDIR")"
|
||||
INCLUDE_PARENT="$(nearest_existing_parent "${INCLUDEDIR}/sharing/linux")"
|
||||
|
||||
if [[ ! -w "$LIB_PARENT" || ! -w "$INCLUDE_PARENT" ]]; then
|
||||
NEEDS_ELEVATION=1
|
||||
fi
|
||||
|
||||
if [[ "$NEEDS_ELEVATION" -eq 1 && "$(id -u)" -ne 0 ]]; then
|
||||
if ! command -v sudo >/dev/null 2>&1; then
|
||||
echo "Install requires elevated privileges, but sudo is not available." >&2
|
||||
exit 1
|
||||
fi
|
||||
INSTALL_PREFIX=(sudo)
|
||||
fi
|
||||
|
||||
if [[ ! -f "$HEADER_SRC" ]]; then
|
||||
echo "Header not found: $HEADER_SRC" >&2
|
||||
echo "Run this script from the workspace root." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$SKIP_BUILD" -eq 0 ]]; then
|
||||
echo "[1/4] Building $TARGET"
|
||||
run_bazel build "$TARGET"
|
||||
else
|
||||
echo "[1/4] Skipping build (--skip-build)"
|
||||
fi
|
||||
|
||||
echo "[2/4] Resolving bazel-bin path"
|
||||
BAZEL_BIN="$(run_bazel info bazel-bin)"
|
||||
LIB_SRC="${BAZEL_BIN}/sharing/linux/libnearby_sharing_api_shared.so"
|
||||
|
||||
if [[ ! -f "$LIB_SRC" ]]; then
|
||||
echo "Shared library not found: $LIB_SRC" >&2
|
||||
echo "Expected Bazel output for $TARGET is missing." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[3/4] Installing library and header"
|
||||
"${INSTALL_PREFIX[@]}" install -d "$LIBDIR"
|
||||
"${INSTALL_PREFIX[@]}" install -d "${INCLUDEDIR}/sharing/linux"
|
||||
"${INSTALL_PREFIX[@]}" install -m 0755 "$LIB_SRC" "$LIBDIR/"
|
||||
"${INSTALL_PREFIX[@]}" install -m 0644 "$HEADER_SRC" "${INCLUDEDIR}/sharing/linux/"
|
||||
|
||||
if command -v ldconfig >/dev/null 2>&1; then
|
||||
echo "[4/4] Refreshing dynamic linker cache"
|
||||
"${INSTALL_PREFIX[@]}" ldconfig
|
||||
else
|
||||
echo "[4/4] ldconfig not found; skipping linker cache refresh"
|
||||
fi
|
||||
|
||||
echo "Installed:"
|
||||
echo " library: $LIBDIR/$(basename "$LIB_SRC")"
|
||||
echo " header : ${INCLUDEDIR}/sharing/linux/$(basename "$HEADER_SRC")"
|
||||
@@ -0,0 +1,142 @@
|
||||
#include "sharing/analytics/analytics_device_settings.h"
|
||||
#include "sharing/analytics/analytics_information.h"
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/share_target.h"
|
||||
|
||||
namespace nearby::sharing::linux {
|
||||
class NoOpAnalyticsRecorder final : public analytics::AnalyticsRecorder {
|
||||
public:
|
||||
void NewEstablishConnection(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::EstablishConnectionStatus
|
||||
connection_status,
|
||||
const ShareTarget& share_target, int transfer_position,
|
||||
int concurrent_connections, int64_t duration_millis,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewAcceptAgreements() override {}
|
||||
void NewDeclineAgreements() override {}
|
||||
void NewAddContact() override {}
|
||||
void NewRemoveContact() override {}
|
||||
void NewTapFeedback() override {}
|
||||
void NewTapHelp() override {}
|
||||
void NewLaunchDeviceContactConsent(
|
||||
location::nearby::proto::sharing::ConsentAcceptanceStatus status)
|
||||
override {}
|
||||
void NewAdvertiseDevicePresenceEnd(int64_t session_id) override {}
|
||||
void NewAdvertiseDevicePresenceStart(
|
||||
int64_t session_id, proto::DeviceVisibility visibility,
|
||||
location::nearby::proto::sharing::SessionStatus status,
|
||||
proto::DataUsage data_usage,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewDescribeAttachments(const AttachmentContainer& attachments) override {}
|
||||
void NewDiscoverShareTarget(
|
||||
const ShareTarget& share_target, int64_t session_id,
|
||||
int64_t latency_since_scanning_start_millis, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package,
|
||||
int64_t latency_since_send_surface_registered_millis) override {}
|
||||
void NewEnableNearbySharing(
|
||||
location::nearby::proto::sharing::NearbySharingStatus status) override {}
|
||||
void NewOpenReceivedAttachments(const AttachmentContainer& attachments,
|
||||
int64_t session_id) override {}
|
||||
void NewProcessReceivedAttachmentsEnd(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::ProcessReceivedAttachmentsStatus status)
|
||||
override {}
|
||||
void NewReceiveAttachmentsEnd(
|
||||
int64_t session_id, int64_t received_bytes,
|
||||
location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewReceiveAttachmentsStart(
|
||||
int64_t session_id, const AttachmentContainer& attachments) override {}
|
||||
void NewReceiveFastInitialization(
|
||||
int64_t timeElapseSinceScreenUnlockMillis) override {}
|
||||
void NewAcceptFastInitialization() override {}
|
||||
void NewDismissFastInitialization() override {}
|
||||
void NewReceiveIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
std::optional<std::string> referrer_package,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewRespondToIntroduction(
|
||||
location::nearby::proto::sharing::ResponseToIntroduction action,
|
||||
int64_t session_id) override {}
|
||||
void NewTapPrivacyNotification() override {}
|
||||
void NewDismissPrivacyNotification() override {}
|
||||
void NewScanForShareTargetsEnd(int64_t session_id) override {}
|
||||
void NewScanForShareTargetsStart(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::SessionStatus status,
|
||||
analytics::AnalyticsInformation analytics_information, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewSendAttachmentsEnd(
|
||||
int64_t session_id, int64_t sent_bytes, const ShareTarget& share_target,
|
||||
location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
int transfer_position, int concurrent_connections,
|
||||
int64_t duration_millis, std::optional<std::string> referrer_package,
|
||||
location::nearby::proto::sharing::ConnectionLayerStatus
|
||||
connection_layer_status,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSendAttachmentsStart(int64_t session_id,
|
||||
const AttachmentContainer& attachments,
|
||||
int transfer_position,
|
||||
int concurrent_connections,
|
||||
bool advanced_protection_enabled,
|
||||
bool advanced_protection_mismatch) override {}
|
||||
void NewSendFastInitialization() override {}
|
||||
void NewSendStart(int64_t session_id, int transfer_position,
|
||||
int concurrent_connections,
|
||||
const ShareTarget& share_target) override {}
|
||||
void NewSendIntroduction(
|
||||
ShareTargetType target_type, int64_t session_id,
|
||||
location::nearby::proto::sharing::DeviceRelationship relationship,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSendIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
int transfer_position, int concurrent_connections,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSetVisibility(proto::DeviceVisibility src_visibility,
|
||||
proto::DeviceVisibility dst_visibility,
|
||||
int64_t duration_millis) override {}
|
||||
void NewDeviceSettings(analytics::AnalyticsDeviceSettings settings) override {
|
||||
}
|
||||
void NewSetDataUsage(proto::DataUsage original_preference,
|
||||
proto::DataUsage preference) override {}
|
||||
void NewAddQuickSettingsTile() override {}
|
||||
void NewRemoveQuickSettingsTile() override {}
|
||||
void NewTapQuickSettingsTile() override {}
|
||||
void NewToggleShowNotification(
|
||||
location::nearby::proto::sharing::ShowNotificationStatus prev_status,
|
||||
location::nearby::proto::sharing::ShowNotificationStatus current_status)
|
||||
override {}
|
||||
void NewSetDeviceName(int device_name_size) override {}
|
||||
void NewRequestSettingPermissions(
|
||||
location::nearby::proto::sharing::PermissionRequestType type,
|
||||
location::nearby::proto::sharing::PermissionRequestResult result)
|
||||
override {}
|
||||
void NewInstallAPKStatus(
|
||||
location::nearby::proto::sharing::InstallAPKStatus status,
|
||||
location::nearby::proto::sharing::ApkSource source) override {}
|
||||
void NewVerifyAPKStatus(
|
||||
location::nearby::proto::sharing::VerifyAPKStatus status,
|
||||
location::nearby::proto::sharing::ApkSource source) override {}
|
||||
void NewRpcCallStatus(absl::string_view rpc_name, RpcDirection direction,
|
||||
int error_code, absl::Duration latency) override {}
|
||||
int64_t GenerateNextId() override { return next_id_++; }
|
||||
|
||||
private:
|
||||
std::atomic<int64_t> next_id_{1};
|
||||
};
|
||||
}
|
||||
@@ -29,23 +29,16 @@
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/flags/nearby_flags.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
#include "sharing/advertisement.h"
|
||||
#include "sharing/analytics/analytics_device_settings.h"
|
||||
#include "sharing/analytics/analytics_information.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/file_attachment.h"
|
||||
#include "sharing/linux/platform/linux_sharing_platform.h"
|
||||
#include "sharing/linux/nearby_noop_analytics_recorder.h"
|
||||
#include "sharing/flags/generated/nearby_sharing_feature_flags.h"
|
||||
#include "sharing/nearby_sharing_service.h"
|
||||
#include "sharing/nearby_sharing_service_factory.h"
|
||||
@@ -163,127 +156,6 @@ NearbySharingService::StatusCodes WaitForStatus(Invoker invoker) {
|
||||
return *status;
|
||||
}
|
||||
|
||||
class NoOpAnalyticsRecorder final : public analytics::AnalyticsRecorder {
|
||||
public:
|
||||
void NewEstablishConnection(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::EstablishConnectionStatus
|
||||
connection_status,
|
||||
const ShareTarget& share_target, int transfer_position,
|
||||
int concurrent_connections, int64_t duration_millis,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewAcceptAgreements() override {}
|
||||
void NewDeclineAgreements() override {}
|
||||
void NewAddContact() override {}
|
||||
void NewRemoveContact() override {}
|
||||
void NewTapFeedback() override {}
|
||||
void NewTapHelp() override {}
|
||||
void NewLaunchDeviceContactConsent(
|
||||
location::nearby::proto::sharing::ConsentAcceptanceStatus status)
|
||||
override {}
|
||||
void NewAdvertiseDevicePresenceEnd(int64_t session_id) override {}
|
||||
void NewAdvertiseDevicePresenceStart(
|
||||
int64_t session_id, proto::DeviceVisibility visibility,
|
||||
location::nearby::proto::sharing::SessionStatus status,
|
||||
proto::DataUsage data_usage,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewDescribeAttachments(const AttachmentContainer& attachments) override {}
|
||||
void NewDiscoverShareTarget(
|
||||
const ShareTarget& share_target, int64_t session_id,
|
||||
int64_t latency_since_scanning_start_millis, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package,
|
||||
int64_t latency_since_send_surface_registered_millis) override {}
|
||||
void NewEnableNearbySharing(
|
||||
location::nearby::proto::sharing::NearbySharingStatus status) override {}
|
||||
void NewOpenReceivedAttachments(const AttachmentContainer& attachments,
|
||||
int64_t session_id) override {}
|
||||
void NewProcessReceivedAttachmentsEnd(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::ProcessReceivedAttachmentsStatus status)
|
||||
override {}
|
||||
void NewReceiveAttachmentsEnd(
|
||||
int64_t session_id, int64_t received_bytes,
|
||||
location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewReceiveAttachmentsStart(
|
||||
int64_t session_id, const AttachmentContainer& attachments) override {}
|
||||
void NewReceiveFastInitialization(
|
||||
int64_t timeElapseSinceScreenUnlockMillis) override {}
|
||||
void NewAcceptFastInitialization() override {}
|
||||
void NewDismissFastInitialization() override {}
|
||||
void NewReceiveIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
std::optional<std::string> referrer_package,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewRespondToIntroduction(
|
||||
location::nearby::proto::sharing::ResponseToIntroduction action,
|
||||
int64_t session_id) override {}
|
||||
void NewTapPrivacyNotification() override {}
|
||||
void NewDismissPrivacyNotification() override {}
|
||||
void NewScanForShareTargetsEnd(int64_t session_id) override {}
|
||||
void NewScanForShareTargetsStart(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::SessionStatus status,
|
||||
analytics::AnalyticsInformation analytics_information, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewSendAttachmentsEnd(
|
||||
int64_t session_id, int64_t sent_bytes, const ShareTarget& share_target,
|
||||
location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
int transfer_position, int concurrent_connections,
|
||||
int64_t duration_millis, std::optional<std::string> referrer_package,
|
||||
location::nearby::proto::sharing::ConnectionLayerStatus
|
||||
connection_layer_status,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSendAttachmentsStart(int64_t session_id,
|
||||
const AttachmentContainer& attachments,
|
||||
int transfer_position,
|
||||
int concurrent_connections,
|
||||
bool advanced_protection_enabled,
|
||||
bool advanced_protection_mismatch) override {}
|
||||
void NewSendFastInitialization() override {}
|
||||
void NewSendStart(int64_t session_id, int transfer_position,
|
||||
int concurrent_connections,
|
||||
const ShareTarget& share_target) override {}
|
||||
void NewSendIntroduction(
|
||||
ShareTargetType target_type, int64_t session_id,
|
||||
location::nearby::proto::sharing::DeviceRelationship relationship,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSendIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
int transfer_position, int concurrent_connections,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSetVisibility(proto::DeviceVisibility src_visibility,
|
||||
proto::DeviceVisibility dst_visibility,
|
||||
int64_t duration_millis) override {}
|
||||
void NewDeviceSettings(analytics::AnalyticsDeviceSettings settings) override {
|
||||
}
|
||||
void NewSetDataUsage(proto::DataUsage original_preference,
|
||||
proto::DataUsage preference) override {}
|
||||
void NewAddQuickSettingsTile() override {}
|
||||
void NewRemoveQuickSettingsTile() override {}
|
||||
void NewTapQuickSettingsTile() override {}
|
||||
void NewToggleShowNotification(
|
||||
location::nearby::proto::sharing::ShowNotificationStatus prev_status,
|
||||
location::nearby::proto::sharing::ShowNotificationStatus current_status)
|
||||
override {}
|
||||
void NewSetDeviceName(int device_name_size) override {}
|
||||
void NewRequestSettingPermissions(
|
||||
location::nearby::proto::sharing::PermissionRequestType type,
|
||||
location::nearby::proto::sharing::PermissionRequestResult result)
|
||||
override {}
|
||||
void NewInstallAPKStatus(
|
||||
location::nearby::proto::sharing::InstallAPKStatus status,
|
||||
location::nearby::proto::sharing::ApkSource source) override {}
|
||||
void NewVerifyAPKStatus(
|
||||
location::nearby::proto::sharing::VerifyAPKStatus status,
|
||||
location::nearby::proto::sharing::ApkSource source) override {}
|
||||
void NewRpcCallStatus(absl::string_view rpc_name, RpcDirection direction,
|
||||
int error_code, absl::Duration latency) override {}
|
||||
int64_t GenerateNextId() override { return next_id_++; }
|
||||
|
||||
private:
|
||||
std::atomic<int64_t> next_id_{1};
|
||||
};
|
||||
|
||||
struct CliState {
|
||||
std::mutex mutex;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
|
||||
|
||||
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
|
||||
|
||||
refresh_compile_commands(
|
||||
name = "refresh_compile_commands",
|
||||
|
||||
# Specify the targets of interest.
|
||||
# For example, specify a dict of targets and any flags required to build.
|
||||
targets = {
|
||||
":tui" : "",
|
||||
},
|
||||
# No need to add flags already in .bazelrc. They're automatically picked up.
|
||||
# If you don't need flags, a list of targets is also okay, as is a single target string.
|
||||
# Wildcard patterns, like //... for everything, *are* allowed here, just like a build.
|
||||
# As are additional targets (+) and subtractions (-), like in bazel query https://docs.bazel.build/versions/main/query.html#expressions
|
||||
# And if you're working on a header-only library, specify a test or binary target that compiles it.
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "tui",
|
||||
srcs = [
|
||||
"main.cc",
|
||||
],
|
||||
deps = [
|
||||
"@ftxui//:ftxui",
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "ftxui/dom/elements.hpp"
|
||||
#include "ftxui/screen/screen.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
using namespace ftxui;
|
||||
auto document = text(L"Hello, FTXUI 6.1.9!") | border;
|
||||
auto screen = Screen::Create(Dimension::Fit(document));
|
||||
|
||||
Render(screen, document);
|
||||
screen.Print();
|
||||
|
||||
// Wait for user input before exiting.
|
||||
std::cout << '\n' << "Press Enter to exit..." << std::flush;
|
||||
std::cin.ignore(9999, '\n');
|
||||
std::cin.clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user