added enable 5ghz toggle for people with intel LAR issues

This commit is contained in:
lasan
2026-04-17 11:47:06 +05:30
parent cf63fe5b5d
commit 4b7b5649e1
6 changed files with 49 additions and 0 deletions
+5
View File
@@ -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;
+1
View File
@@ -111,6 +111,7 @@ class __attribute__((visibility("default"))) NearbySharingApi {
void Accept(int64_t share_target_id, std::function<void(StatusCode)> callback);
void Reject(int64_t share_target_id, std::function<void(StatusCode)> callback);
void Cancel(int64_t share_target_id, std::function<void(StatusCode)> callback);
void Set5GhzHotspotEnabled(bool enabled);
void SetDeviceName(const std::string& device_name);
void Shutdown(std::function<void(StatusCode)> callback);
@@ -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
}
}
}
}
@@ -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_;
@@ -37,6 +37,7 @@ FileShareTrayController::~FileShareTrayController() {
void FileShareTrayController::initializeService() {
service_ = std::make_unique<NearbySharingApi>(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")) {
@@ -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();