Commit 28beda6b authored by Josh Nohle's avatar Josh Nohle Committed by Commit Bot

[DeviceSync v2] Move ShouldUseV2DeviceSync to chromeos_features

We also add the function ShouldDeprecateV1DeviceSync for future use.

We adjust the DeviceSync service unit tests to check the Chrome OS
feature flags.

Bug: 951969, 1019206
Change-Id: I5cd8de6521131cf1cca672f4dc7b6115f93cd06a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1907834Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Josh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714490}
parent 1f5e1d17
...@@ -316,9 +316,22 @@ bool IsSplitSettingsSyncEnabled() { ...@@ -316,9 +316,22 @@ bool IsSplitSettingsSyncEnabled() {
return base::FeatureList::IsEnabled(kSplitSettingsSync); return base::FeatureList::IsEnabled(kSplitSettingsSync);
} }
bool ShouldDeprecateV1DeviceSync() {
return ShouldUseV2DeviceSync() &&
base::FeatureList::IsEnabled(
chromeos::features::kCryptAuthV1DeviceSyncDeprecate);
}
bool ShouldShowPlayStoreInDemoMode() { bool ShouldShowPlayStoreInDemoMode() {
return base::FeatureList::IsEnabled(kShowPlayInDemoMode); return base::FeatureList::IsEnabled(kShowPlayInDemoMode);
} }
bool ShouldUseV2DeviceSync() {
return base::FeatureList::IsEnabled(
chromeos::features::kCryptAuthV2Enrollment) &&
base::FeatureList::IsEnabled(
chromeos::features::kCryptAuthV2DeviceSync);
}
} // namespace features } // namespace features
} // namespace chromeos } // namespace chromeos
...@@ -141,10 +141,13 @@ bool IsInstantTetheringBackgroundAdvertisingSupported(); ...@@ -141,10 +141,13 @@ bool IsInstantTetheringBackgroundAdvertisingSupported();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsParentalControlsSettingsEnabled(); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsParentalControlsSettingsEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsSplitSettingsEnabled(); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsSplitSettingsEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsSplitSettingsSyncEnabled(); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsSplitSettingsSyncEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool ShouldDeprecateV1DeviceSync();
// TODO(michaelpg): Remove after M71 branch to re-enable Play Store by default. // TODO(michaelpg): Remove after M71 branch to re-enable Play Store by default.
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool ShouldShowPlayStoreInDemoMode(); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool ShouldShowPlayStoreInDemoMode();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool ShouldUseV2DeviceSync();
// Keep alphabetized. // Keep alphabetized.
} // namespace features } // namespace features
......
...@@ -89,13 +89,6 @@ enum class DeviceSyncSetSoftwareFeature { ...@@ -89,13 +89,6 @@ enum class DeviceSyncSetSoftwareFeature {
kMaxValue = kUnexpectedClientFeature kMaxValue = kUnexpectedClientFeature
}; };
bool ShouldUseV2DeviceSync() {
return base::FeatureList::IsEnabled(
chromeos::features::kCryptAuthV2Enrollment) &&
base::FeatureList::IsEnabled(
chromeos::features::kCryptAuthV2DeviceSync);
}
DeviceSyncRequestFailureReason GetDeviceSyncRequestFailureReason( DeviceSyncRequestFailureReason GetDeviceSyncRequestFailureReason(
mojom::NetworkRequestResult failure_reason) { mojom::NetworkRequestResult failure_reason) {
switch (failure_reason) { switch (failure_reason) {
...@@ -292,7 +285,7 @@ void DeviceSyncImpl::RegisterProfilePrefs(PrefRegistrySimple* registry) { ...@@ -292,7 +285,7 @@ void DeviceSyncImpl::RegisterProfilePrefs(PrefRegistrySimple* registry) {
CryptAuthEnrollmentManagerImpl::RegisterPrefs(registry); CryptAuthEnrollmentManagerImpl::RegisterPrefs(registry);
} }
if (ShouldUseV2DeviceSync()) { if (features::ShouldUseV2DeviceSync()) {
CryptAuthDeviceRegistryImpl::RegisterPrefs(registry); CryptAuthDeviceRegistryImpl::RegisterPrefs(registry);
} }
} }
...@@ -370,7 +363,7 @@ void DeviceSyncImpl::ForceSyncNow(ForceSyncNowCallback callback) { ...@@ -370,7 +363,7 @@ void DeviceSyncImpl::ForceSyncNow(ForceSyncNowCallback callback) {
cryptauth_device_manager_->ForceSyncNow(cryptauth::INVOCATION_REASON_MANUAL); cryptauth_device_manager_->ForceSyncNow(cryptauth::INVOCATION_REASON_MANUAL);
if (ShouldUseV2DeviceSync()) { if (features::ShouldUseV2DeviceSync()) {
cryptauth_v2_device_manager_->ForceDeviceSyncNow( cryptauth_v2_device_manager_->ForceDeviceSyncNow(
cryptauthv2::ClientMetadata::MANUAL, base::nullopt /* session_id */); cryptauthv2::ClientMetadata::MANUAL, base::nullopt /* session_id */);
} }
...@@ -674,7 +667,7 @@ void DeviceSyncImpl::InitializeCryptAuthManagementObjects() { ...@@ -674,7 +667,7 @@ void DeviceSyncImpl::InitializeCryptAuthManagementObjects() {
clock_, cryptauth_client_factory_.get(), cryptauth_gcm_manager_.get(), clock_, cryptauth_client_factory_.get(), cryptauth_gcm_manager_.get(),
profile_prefs_); profile_prefs_);
if (ShouldUseV2DeviceSync()) { if (features::ShouldUseV2DeviceSync()) {
cryptauth_device_registry_ = cryptauth_device_registry_ =
CryptAuthDeviceRegistryImpl::Factory::Get()->BuildInstance( CryptAuthDeviceRegistryImpl::Factory::Get()->BuildInstance(
profile_prefs_); profile_prefs_);
...@@ -697,7 +690,7 @@ void DeviceSyncImpl::CompleteInitializationAfterSuccessfulEnrollment() { ...@@ -697,7 +690,7 @@ void DeviceSyncImpl::CompleteInitializationAfterSuccessfulEnrollment() {
// Now that enrollment has completed, the current device has been registered // Now that enrollment has completed, the current device has been registered
// with the CryptAuth back-end and can begin monitoring synced devices. // with the CryptAuth back-end and can begin monitoring synced devices.
cryptauth_device_manager_->Start(); cryptauth_device_manager_->Start();
if (ShouldUseV2DeviceSync()) { if (features::ShouldUseV2DeviceSync()) {
cryptauth_v2_device_manager_->Start(); cryptauth_v2_device_manager_->Start();
} }
...@@ -740,7 +733,7 @@ void DeviceSyncImpl::OnSetSoftwareFeatureStateSuccess() { ...@@ -740,7 +733,7 @@ void DeviceSyncImpl::OnSetSoftwareFeatureStateSuccess() {
cryptauth_device_manager_->ForceSyncNow( cryptauth_device_manager_->ForceSyncNow(
cryptauth::INVOCATION_REASON_FEATURE_TOGGLED); cryptauth::INVOCATION_REASON_FEATURE_TOGGLED);
if (ShouldUseV2DeviceSync()) { if (features::ShouldUseV2DeviceSync()) {
cryptauth_v2_device_manager_->ForceDeviceSyncNow( cryptauth_v2_device_manager_->ForceDeviceSyncNow(
cryptauthv2::ClientMetadata::FEATURE_TOGGLED, cryptauthv2::ClientMetadata::FEATURE_TOGGLED,
base::nullopt /* session_id */); base::nullopt /* session_id */);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment