mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 07:36:10 -04:00
added linux feature flag to enable 5ghz hotspot
This commit is contained in:
@@ -14,8 +14,6 @@
|
||||
|
||||
#load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||
#refresh_compile_commands(
|
||||
# name = "refresh_compile_commands",
|
||||
@@ -34,12 +32,15 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||
# # And if you're working on a header-only library, specify a test or binary target that compiles it.
|
||||
#)
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
cc_library(
|
||||
name = "types",
|
||||
srcs = [
|
||||
"device_info.cc",
|
||||
#"log_message.cc",
|
||||
"timer.cc",
|
||||
"linux_flags.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"atomic_boolean.h",
|
||||
@@ -57,6 +58,7 @@ cc_library(
|
||||
"submittable_executor.h",
|
||||
"timer.h",
|
||||
"thread_pool.h",
|
||||
"linux_flags.h",
|
||||
#"log_message.h",
|
||||
"utils.h",
|
||||
],
|
||||
@@ -152,10 +154,10 @@ cc_library(
|
||||
srcs = [
|
||||
"crypto.cc",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
linkopts= [
|
||||
linkopts = [
|
||||
"-lcrypto",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//internal/platform:base",
|
||||
"//internal/platform/implementation:types",
|
||||
@@ -168,7 +170,6 @@ cc_library(
|
||||
srcs = [
|
||||
"system_clock.cc",
|
||||
],
|
||||
alwayslink = True,
|
||||
visibility = [
|
||||
"//sharing/linux:__pkg__",
|
||||
],
|
||||
@@ -177,6 +178,7 @@ cc_library(
|
||||
"//internal/platform/implementation:types",
|
||||
"@com_google_absl//absl/time",
|
||||
],
|
||||
alwayslink = True,
|
||||
)
|
||||
|
||||
cc_library(
|
||||
@@ -242,6 +244,7 @@ cc_library(
|
||||
":crypto", # build_cleaner: keep
|
||||
":system_clock",
|
||||
":types",
|
||||
"//connections/implementation/flags:connections_flags",
|
||||
"//internal/flags:nearby_flags",
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:cancellation_flag",
|
||||
@@ -256,7 +259,6 @@ cc_library(
|
||||
"//internal/platform/implementation/shared:count_down_latch",
|
||||
"//internal/platform/implementation/shared:file",
|
||||
"//proto/mediums:ble_frames_cc_proto",
|
||||
"//connections/implementation/flags:connections_flags",
|
||||
"@com_google_absl//absl/base:core_headers",
|
||||
"@com_google_absl//absl/container:flat_hash_map",
|
||||
"@com_google_absl//absl/functional:any_invocable",
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2026 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.
|
||||
|
||||
#include "internal/platform/implementation/linux/linux_flags.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace nearby::linux {
|
||||
namespace {
|
||||
|
||||
std::atomic_bool kEnable5GhzHotspot = true;
|
||||
|
||||
} // namespace
|
||||
|
||||
bool Is5GhzHotspotEnabled() { return kEnable5GhzHotspot.load(); }
|
||||
|
||||
void Set5GhzHotspotEnabled(bool enabled) { kEnable5GhzHotspot.store(enabled); }
|
||||
|
||||
} // namespace nearby::linux
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2026 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 PLATFORM_IMPL_LINUX_LINUX_FLAGS_H_
|
||||
#define PLATFORM_IMPL_LINUX_LINUX_FLAGS_H_
|
||||
|
||||
namespace nearby::linux {
|
||||
|
||||
bool Is5GhzHotspotEnabled();
|
||||
void Set5GhzHotspotEnabled(bool enabled);
|
||||
|
||||
} // namespace nearby::linux
|
||||
|
||||
#endif // PLATFORM_IMPL_LINUX_LINUX_FLAGS_H_
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <random>
|
||||
|
||||
#include "internal/platform/implementation/linux/dbus.h"
|
||||
#include "internal/platform/implementation/linux/linux_flags.h"
|
||||
#include "internal/platform/implementation/linux/network_manager.h"
|
||||
#include "internal/platform/implementation/linux/network_manager_access_point.h"
|
||||
#include "internal/platform/implementation/linux/utils.h"
|
||||
@@ -164,7 +165,9 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot(
|
||||
api::WifiCapability& capability = wireless_device_->GetCapability();
|
||||
std::string selected_band;
|
||||
int selected_channel = kPreferred24GhzChannel;
|
||||
if (capability.supports_6_ghz || capability.supports_5_ghz) {
|
||||
const bool enable_5ghz_hotspot = Is5GhzHotspotEnabled();
|
||||
if (enable_5ghz_hotspot &&
|
||||
(capability.supports_6_ghz || capability.supports_5_ghz)) {
|
||||
selected_band = "a"; // 5/6 GHz - NetworkManager uses "a" for both 5 GHz and 6 GHz
|
||||
selected_channel = kPreferred5GhzChannel;
|
||||
LOG(INFO) << __func__
|
||||
@@ -173,9 +176,16 @@ bool NetworkManagerWifiHotspotMedium::StartWifiHotspot(
|
||||
} else {
|
||||
selected_band = "bg"; // 2.4 GHz
|
||||
selected_channel = kPreferred24GhzChannel;
|
||||
LOG(INFO) << __func__
|
||||
<< ": Device supports only 2.4 GHz, using 2.4 GHz band on "
|
||||
<< "channel " << selected_channel;
|
||||
if (!enable_5ghz_hotspot &&
|
||||
(capability.supports_6_ghz || capability.supports_5_ghz)) {
|
||||
LOG(INFO) << __func__
|
||||
<< ": 5/6 GHz hotspot is disabled by feature flag, using 2.4 "
|
||||
<< "GHz band on channel " << selected_channel;
|
||||
} else {
|
||||
LOG(INFO) << __func__
|
||||
<< ": Device supports only 2.4 GHz, using 2.4 GHz band on "
|
||||
<< "channel " << selected_channel;
|
||||
}
|
||||
}
|
||||
|
||||
const int32_t fallback_channel_width =
|
||||
|
||||
Reference in New Issue
Block a user