Remove unused constants and hide some from public interface
BUG:24267885
Change-Id: Ibfb853b04e6d63dba4372453484595ede7bb1cb1
Reviewed-on: https://weave-review.googlesource.com/1215
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/libweave/include/weave/privet.h b/libweave/include/weave/privet.h
index a50548a..25f15a4 100644
--- a/libweave/include/weave/privet.h
+++ b/libweave/include/weave/privet.h
@@ -9,26 +9,12 @@
#include <vector>
#include <base/callback.h>
+#include <weave/settings.h>
namespace weave {
-enum class PairingType {
- kPinCode,
- kEmbeddedCode,
- kUltrasound32,
- kAudible32,
-};
-
-enum class WifiSetupState {
- kDisabled,
- kBootstrapping,
- kMonitoring,
- kConnecting,
-};
-
class Privet {
public:
- using OnWifiSetupChangedCallback = base::Callback<void(WifiSetupState state)>;
using OnPairingStartedCallback =
base::Callback<void(const std::string& session_id,
PairingType pairing_type,
diff --git a/libweave/include/weave/settings.h b/libweave/include/weave/settings.h
index c4352f0..a2f3ded 100644
--- a/libweave/include/weave/settings.h
+++ b/libweave/include/weave/settings.h
@@ -9,7 +9,6 @@
#include <string>
#include <base/time/time.h>
-#include <weave/privet.h>
namespace weave {
@@ -21,6 +20,12 @@
kOwner,
};
+// Type client-device pairing.
+enum class PairingType {
+ kPinCode,
+ kEmbeddedCode,
+};
+
struct Settings {
// Model specific information. Must be set by ConfigStore::LoadDefaults.
std::string firmware_version;
diff --git a/libweave/src/privet/mock_delegates.h b/libweave/src/privet/mock_delegates.h
index 20f6877..48227ae 100644
--- a/libweave/src/privet/mock_delegates.h
+++ b/libweave/src/privet/mock_delegates.h
@@ -89,12 +89,11 @@
EXPECT_CALL(*this, GetPairingTypes())
.WillRepeatedly(Return(std::set<PairingType>{
PairingType::kPinCode, PairingType::kEmbeddedCode,
- PairingType::kUltrasound32, PairingType::kAudible32,
}));
EXPECT_CALL(*this, GetCryptoTypes())
.WillRepeatedly(Return(std::set<CryptoType>{
- CryptoType::kSpake_p224, CryptoType::kSpake_p256,
+ CryptoType::kSpake_p224,
}));
EXPECT_CALL(*this, StartPairing(_, _, _, _, _))
diff --git a/libweave/src/privet/privet_handler_unittest.cc b/libweave/src/privet/privet_handler_unittest.cc
index 001ac3d..6829984 100644
--- a/libweave/src/privet/privet_handler_unittest.cc
+++ b/libweave/src/privet/privet_handler_unittest.cc
@@ -313,13 +313,10 @@
],
'pairing': [
'pinCode',
- 'embeddedCode',
- 'ultrasound32',
- 'audible32'
+ 'embeddedCode'
],
'crypto': [
- 'p224_spake2',
- 'p256_spake2'
+ 'p224_spake2'
]
},
'wifi': {
@@ -346,7 +343,7 @@
EXPECT_PRED2(IsEqualError, CodeWithReason(400, "invalidParams"),
HandleRequest("/privet/v3/pairing/start",
- "{'pairing':'code','crypto':'p256_spake2'}"));
+ "{'pairing':'code','crypto':'p224_spake2'}"));
}
TEST_F(PrivetHandlerTest, PairingStart) {
@@ -354,7 +351,7 @@
IsEqualJson,
"{'deviceCommitment': 'testCommitment', 'sessionId': 'testSession'}",
HandleRequest("/privet/v3/pairing/start",
- "{'pairing': 'embeddedCode', 'crypto': 'p256_spake2'}"));
+ "{'pairing': 'embeddedCode', 'crypto': 'p224_spake2'}"));
}
TEST_F(PrivetHandlerTest, PairingConfirm) {
diff --git a/libweave/src/privet/privet_types.cc b/libweave/src/privet/privet_types.cc
index 3cf0ace..3b801f4 100644
--- a/libweave/src/privet/privet_types.cc
+++ b/libweave/src/privet/privet_types.cc
@@ -24,8 +24,6 @@
const EnumToStringMap<PairingType>::Map kPairingTypeMap[] = {
{PairingType::kPinCode, "pinCode"},
{PairingType::kEmbeddedCode, "embeddedCode"},
- {PairingType::kUltrasound32, "ultrasound32"},
- {PairingType::kAudible32, "audible32"},
};
const EnumToStringMap<ConnectionState::Status>::Map kConnectionStateMap[] = {
@@ -50,7 +48,6 @@
const EnumToStringMap<CryptoType>::Map kCryptoTypeMap[] = {
{CryptoType::kNone, "none"},
{CryptoType::kSpake_p224, "p224_spake2"},
- {CryptoType::kSpake_p256, "p256_spake2"},
};
const EnumToStringMap<AuthScope>::Map kAuthScopeMap[] = {
@@ -60,13 +57,6 @@
{AuthScope::kOwner, "owner"},
};
-const EnumToStringMap<WifiSetupState>::Map kWifiSetupStateMap[] = {
- {WifiSetupState::kDisabled, "disabled"},
- {WifiSetupState::kBootstrapping, "waiting"},
- {WifiSetupState::kMonitoring, "monitoring"},
- {WifiSetupState::kConnecting, "connecting"},
-};
-
const EnumToStringMap<Network::State>::Map kNetworkStateMap[] = {
{Network::State::kOffline, "offline"},
{Network::State::kFailure, "failure"},
@@ -101,10 +91,6 @@
: EnumToStringMap(kAuthScopeMap) {}
template <>
-LIBWEAVE_EXPORT EnumToStringMap<WifiSetupState>::EnumToStringMap()
- : EnumToStringMap(kWifiSetupStateMap) {}
-
-template <>
LIBWEAVE_EXPORT EnumToStringMap<Network::State>::EnumToStringMap()
: EnumToStringMap(kNetworkStateMap) {}
diff --git a/libweave/src/privet/privet_types.h b/libweave/src/privet/privet_types.h
index f9ea8b7..9c05be1 100644
--- a/libweave/src/privet/privet_types.h
+++ b/libweave/src/privet/privet_types.h
@@ -17,7 +17,6 @@
enum class CryptoType {
kNone,
kSpake_p224,
- kSpake_p256,
};
enum class WifiType {
diff --git a/libweave/src/privet/security_manager.cc b/libweave/src/privet/security_manager.cc
index 8d896d9..9b8e853 100644
--- a/libweave/src/privet/security_manager.cc
+++ b/libweave/src/privet/security_manager.cc
@@ -218,11 +218,6 @@
CHECK(!embedded_code_.empty());
code = embedded_code_;
break;
- case PairingType::kUltrasound32:
- case PairingType::kAudible32: {
- code = base::RandBytesAsString(4);
- break;
- }
case PairingType::kPinCode:
code = base::StringPrintf("%04i", base::RandInt(0, 9999));
break;
diff --git a/libweave/src/privet/wifi_bootstrap_manager.cc b/libweave/src/privet/wifi_bootstrap_manager.cc
index ee8b15e..7e439e3 100644
--- a/libweave/src/privet/wifi_bootstrap_manager.cc
+++ b/libweave/src/privet/wifi_bootstrap_manager.cc
@@ -18,6 +18,16 @@
namespace weave {
namespace privet {
+namespace {
+
+const EnumToStringMap<WifiBootstrapManager::State>::Map kWifiSetupStateMap[] = {
+ {WifiBootstrapManager::State::kDisabled, "disabled"},
+ {WifiBootstrapManager::State::kBootstrapping, "waiting"},
+ {WifiBootstrapManager::State::kMonitoring, "monitoring"},
+ {WifiBootstrapManager::State::kConnecting, "connecting"},
+};
+}
+
using provider::Network;
WifiBootstrapManager::WifiBootstrapManager(Config* config,
@@ -259,4 +269,10 @@
}
} // namespace privet
+
+template <>
+LIBWEAVE_EXPORT
+EnumToStringMap<privet::WifiBootstrapManager::State>::EnumToStringMap()
+ : EnumToStringMap(privet::kWifiSetupStateMap) {}
+
} // namespace weave
diff --git a/libweave/src/privet/wifi_bootstrap_manager.h b/libweave/src/privet/wifi_bootstrap_manager.h
index aa908a3..d93884f 100644
--- a/libweave/src/privet/wifi_bootstrap_manager.h
+++ b/libweave/src/privet/wifi_bootstrap_manager.h
@@ -37,7 +37,12 @@
class WifiBootstrapManager : public WifiDelegate {
public:
- using State = WifiSetupState;
+ enum class State {
+ kDisabled,
+ kBootstrapping,
+ kMonitoring,
+ kConnecting,
+ };
WifiBootstrapManager(Config* config,
provider::TaskRunner* task_runner,