diff --git a/sharing/linux/nearby_sharing_api.cc b/sharing/linux/nearby_sharing_api.cc index bf511920..febeac11 100644 --- a/sharing/linux/nearby_sharing_api.cc +++ b/sharing/linux/nearby_sharing_api.cc @@ -17,6 +17,7 @@ #include "internal/base/files.h" #include "internal/crypto_cros/ec_private_key.h" #include "internal/flags/nearby_flags.h" +#include "internal/platform/implementation/linux/linux_flags.h" #include "sharing/analytics/analytics_recorder.h" #include "sharing/attachment_container.h" #include "sharing/file_attachment.h" @@ -577,6 +578,10 @@ void NearbySharingApi::Cancel(int64_t share_target_id, }); } +void NearbySharingApi::Set5GhzHotspotEnabled(bool enabled) { + nearby::linux::Set5GhzHotspotEnabled(enabled); +} + void NearbySharingApi::SetDeviceName(const std::string& device_name) { if (impl_->service == nullptr || device_name.empty()) { return; diff --git a/sharing/linux/nearby_sharing_api.h b/sharing/linux/nearby_sharing_api.h index 22569b27..dd8baee5 100644 --- a/sharing/linux/nearby_sharing_api.h +++ b/sharing/linux/nearby_sharing_api.h @@ -111,6 +111,7 @@ class __attribute__((visibility("default"))) NearbySharingApi { void Accept(int64_t share_target_id, std::function callback); void Reject(int64_t share_target_id, std::function callback); void Cancel(int64_t share_target_id, std::function callback); + void Set5GhzHotspotEnabled(bool enabled); void SetDeviceName(const std::string& device_name); void Shutdown(std::function callback); diff --git a/sharing/linux/qml_tray_app/components/SettingsPanel.qml b/sharing/linux/qml_tray_app/components/SettingsPanel.qml index 5aa8c7d7..8677681a 100644 --- a/sharing/linux/qml_tray_app/components/SettingsPanel.qml +++ b/sharing/linux/qml_tray_app/components/SettingsPanel.qml @@ -146,6 +146,21 @@ Drawer { onToggled: fileShareController.autoAcceptIncoming = checked } } + + RowLayout { + Layout.fillWidth: true + spacing: 10 + Label { + Layout.fillWidth: true + color: root.textPrimary + font.pixelSize: 13 + text: "Enable 5 GHz hotspot" + } + ThemedToggle { + checked: fileShareController.enable5GhzHotspot + onToggled: fileShareController.enable5GhzHotspot = checked + } + } } } diff --git a/sharing/linux/qml_tray_app/file_share_state.h b/sharing/linux/qml_tray_app/file_share_state.h index 47b80b6e..d95f190e 100644 --- a/sharing/linux/qml_tray_app/file_share_state.h +++ b/sharing/linux/qml_tray_app/file_share_state.h @@ -20,6 +20,7 @@ class FileShareState { QString statusMessage() const { return status_message_; } bool running() const { return running_; } bool autoAcceptIncoming() const { return auto_accept_incoming_; } + bool enable5GhzHotspot() const { return enable_5ghz_hotspot_; } QString pendingSendFileName() const { return pending_send_file_name_; } QString pendingSendFilePath() const { return pending_send_file_path_; } @@ -40,6 +41,7 @@ class FileShareState { void SetStatusMessage(const QString& message) { status_message_ = message; } void SetRunning(bool running) { running_ = running; } void SetAutoAcceptIncoming(bool enabled) { auto_accept_incoming_ = enabled; } + void SetEnable5GhzHotspot(bool enabled) { enable_5ghz_hotspot_ = enabled; } void SetPendingSendFile(const QString& file_path, const QString& file_name, qlonglong target_id) { @@ -91,6 +93,7 @@ class FileShareState { QString status_message_ = QStringLiteral("Idle"); bool running_ = false; bool auto_accept_incoming_ = true; + bool enable_5ghz_hotspot_ = true; // QR Code QString qr_code_url_; diff --git a/sharing/linux/qml_tray_app/file_share_tray_controller.cc b/sharing/linux/qml_tray_app/file_share_tray_controller.cc index b42de0ca..7f692bb1 100644 --- a/sharing/linux/qml_tray_app/file_share_tray_controller.cc +++ b/sharing/linux/qml_tray_app/file_share_tray_controller.cc @@ -37,6 +37,7 @@ FileShareTrayController::~FileShareTrayController() { void FileShareTrayController::initializeService() { service_ = std::make_unique(state_.deviceName().toStdString()); + service_->Set5GhzHotspotEnabled(state_.enable5GhzHotspot()); state_.SetQrCodeData(QString::fromStdString(service_->GetQrCodeUrl()), {}, 0); updateQrCodeData(); emit qrCodeUrlChanged(); @@ -245,6 +246,10 @@ void FileShareTrayController::loadSettings() { settings.value(QStringLiteral("autoAcceptIncoming"), true).toBool(); state_.SetAutoAcceptIncoming(stored_auto_accept); + const bool stored_enable_5ghz_hotspot = + settings.value(QStringLiteral("enable5GhzHotspot"), true).toBool(); + state_.SetEnable5GhzHotspot(stored_enable_5ghz_hotspot); + const QString stored_log_path = settings.value(QStringLiteral("logPath"), QStringLiteral("/tmp/nearby_qml_file_tray.log")) .toString() @@ -258,6 +263,8 @@ void FileShareTrayController::saveSettings() const { QSettings settings(QStringLiteral("Nearby"), QStringLiteral("QmlFileTrayApp")); settings.setValue(QStringLiteral("deviceName"), state_.deviceName()); settings.setValue(QStringLiteral("autoAcceptIncoming"), state_.autoAcceptIncoming()); + settings.setValue(QStringLiteral("enable5GhzHotspot"), + state_.enable5GhzHotspot()); settings.setValue(QStringLiteral("logPath"), state_.logPath()); } @@ -287,6 +294,18 @@ void FileShareTrayController::setAutoAcceptIncoming(bool enabled) { emit autoAcceptIncomingChanged(); } +void FileShareTrayController::setEnable5GhzHotspot(bool enabled) { + if (enabled == state_.enable5GhzHotspot()) { + return; + } + state_.SetEnable5GhzHotspot(enabled); + if (service_) { + service_->Set5GhzHotspotEnabled(enabled); + } + saveSettings(); + emit enable5GhzHotspotChanged(); +} + void FileShareTrayController::setLogPath(const QString& path) { const QString trimmed = path.trimmed(); if (trimmed.isEmpty() || trimmed == state_.logPath()) { @@ -558,6 +577,8 @@ void FileShareTrayController::notifyStateChange(const QString& property) { emit runningChanged(); } else if (property == QStringLiteral("autoAcceptIncoming")) { emit autoAcceptIncomingChanged(); + } else if (property == QStringLiteral("enable5GhzHotspot")) { + emit enable5GhzHotspotChanged(); } else if (property == QStringLiteral("discoveredTargets")) { emit discoveredTargetsChanged(); } else if (property == QStringLiteral("transfers")) { diff --git a/sharing/linux/qml_tray_app/file_share_tray_controller.h b/sharing/linux/qml_tray_app/file_share_tray_controller.h index 99a0ff92..05f88dbe 100644 --- a/sharing/linux/qml_tray_app/file_share_tray_controller.h +++ b/sharing/linux/qml_tray_app/file_share_tray_controller.h @@ -20,6 +20,7 @@ class FileShareTrayController : public QObject { Q_PROPERTY(QVariantList discoveredTargets READ discoveredTargets NOTIFY discoveredTargetsChanged) Q_PROPERTY(QVariantList transfers READ transfers NOTIFY transfersChanged) Q_PROPERTY(bool autoAcceptIncoming READ autoAcceptIncoming WRITE setAutoAcceptIncoming NOTIFY autoAcceptIncomingChanged) + Q_PROPERTY(bool enable5GhzHotspot READ enable5GhzHotspot WRITE setEnable5GhzHotspot NOTIFY enable5GhzHotspotChanged) Q_PROPERTY(QString qrCodeUrl READ qrCodeUrl NOTIFY qrCodeUrlChanged) Q_PROPERTY(QStringList qrCodeRows READ qrCodeRows NOTIFY qrCodeChanged) Q_PROPERTY(int qrCodeSize READ qrCodeSize NOTIFY qrCodeChanged) @@ -39,6 +40,7 @@ class FileShareTrayController : public QObject { QVariantList discoveredTargets() const { return state_.discoveredTargets(); } QVariantList transfers() const { return state_.transfers(); } bool autoAcceptIncoming() const { return state_.autoAcceptIncoming(); } + bool enable5GhzHotspot() const { return state_.enable5GhzHotspot(); } QString qrCodeUrl() const { return state_.qrCodeUrl(); } QStringList qrCodeRows() const { return state_.qrCodeRows(); } int qrCodeSize() const { return state_.qrCodeSize(); } @@ -47,6 +49,7 @@ class FileShareTrayController : public QObject { // Public methods void setDeviceName(const QString& device_name); void setAutoAcceptIncoming(bool enabled); + void setEnable5GhzHotspot(bool enabled); void setLogPath(const QString& path); Q_INVOKABLE void start(); @@ -69,6 +72,7 @@ class FileShareTrayController : public QObject { void discoveredTargetsChanged(); void transfersChanged(); void autoAcceptIncomingChanged(); + void enable5GhzHotspotChanged(); void qrCodeUrlChanged(); void qrCodeChanged(); void logPathChanged();