Expose NearbyFlags through Objective-C package so BLE v2 can more easily be enabled in the Swift SDK

PiperOrigin-RevId: 600790011
This commit is contained in:
Nick Bourdakos
2024-01-23 08:04:03 -08:00
committed by Copybara-Service
parent caa82a41d8
commit 5fb7f69830
4 changed files with 63 additions and 1 deletions
+3 -1
View File
@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load("//third_party/nearby:minimum_os.bzl", "IOS_LATEST_TEST_RUNNER", "IOS_MINIMUM_OS")
load("//tools/build_defs/apple:ios.bzl", "ios_unit_test")
load("//tools/build_defs/swift:swift_library.bzl", "swift_library")
load("//third_party/nearby:minimum_os.bzl", "IOS_LATEST_TEST_RUNNER", "IOS_MINIMUM_OS")
licenses(["notice"])
@@ -33,6 +33,8 @@ objc_library(
deps = [
"//connections:core",
"//connections:core_types",
"//connections/implementation/flags:connections_flags",
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform/implementation/apple", # buildcleaner: keep
"//third_party/apple_frameworks:Foundation",
@@ -0,0 +1,36 @@
// Copyright 2024 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.
#import "connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCFlags.h"
#import <Foundation/Foundation.h>
#include <memory>
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
#include "internal/flags/nearby_flags.h"
@implementation GNCFlags
+ (BOOL)enableBLEV2 {
return nearby::NearbyFlags::GetInstance().GetBoolFlag(
nearby::connections::config_package_nearby::nearby_connections_feature::kEnableBleV2);
}
+ (void)setEnableBLEV2:(BOOL)value {
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
nearby::connections::config_package_nearby::nearby_connections_feature::kEnableBleV2, value);
}
@end
@@ -0,0 +1,23 @@
// Copyright 2024 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.
#import <Foundation/Foundation.h>
/** A utility class for accessing and overriding Nearby feature flags. */
@interface GNCFlags : NSObject
/** Whether BLE v2 is enabled in the Nearby Connections SDK. */
@property(nonatomic, class) BOOL enableBLEV2;
@end
@@ -19,6 +19,7 @@
#import "GNCDiscoveryDelegate.h"
#import "GNCDiscoveryOptions.h"
#import "GNCError.h"
#import "GNCFlags.h"
#import "GNCPayload.h"
#import "GNCPayloadDelegate.h"
#import "GNCStrategy.h"