Commit da07836f authored by Kazuhiro Inaba's avatar Kazuhiro Inaba Committed by Commit Bot

Remove the legacy fallback code path for the ARC backup settings.

crrev.com/517091 switched the backup settings sync path from ArcIntentHelper
to a new special apk. This CL cleans up the legacy ArcIntentHelper path now.

BUG=783567
TEST=Manual: (un)tick backup in ARC optin and confirm it in Android settings

Change-Id: I77c123cc4be1e310303cad329249162e2ecd900b
Reviewed-on: https://chromium-review.googlesource.com/807487
Commit-Queue: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: default avatarShuhei Takahashi <nya@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522314}
parent 70caa452
......@@ -431,14 +431,6 @@ void ArcSettingsServiceImpl::SyncBackupEnabled() const {
DCHECK(value->is_bool());
backup_settings->SetBackupEnabled(value->GetBool(),
!pref->IsUserModifiable());
} else {
// TODO(crbug.com/783567): Remove this code path after we made sure we
// rolled the ARC image that implements backup_settings.
//
// Fallback to use intent broadcast, if the new method is not available.
SendBoolPrefSettingsBroadcast(
prefs::kArcBackupRestoreEnabled,
"org.chromium.arc.intent_helper.SET_BACKUP_ENABLED");
}
if (GetPrefs()->IsManagedPreference(prefs::kArcBackupRestoreEnabled)) {
......
......@@ -29,6 +29,7 @@
#include "components/arc/arc_service_manager.h"
#include "components/arc/arc_util.h"
#include "components/arc/test/connection_holder_util.h"
#include "components/arc/test/fake_backup_settings_instance.h"
#include "components/arc/test/fake_intent_helper_instance.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
......@@ -178,8 +179,6 @@ constexpr char kWifi1Guid[] = "{wifi1_guid}";
constexpr char kONCPacUrl[] = "http://domain.com/x";
constexpr char kBackupBroadcastAction[] =
"org.chromium.arc.intent_helper.SET_BACKUP_ENABLED";
constexpr char kLocationServiceBroadcastAction[] =
"org.chromium.arc.intent_helper.SET_LOCATION_SERVICE_ENABLED";
constexpr char kSetProxyBroadcastAction[] =
......@@ -245,9 +244,24 @@ class ArcSettingsServiceTest : public InProcessBrowserTest {
->SetInstance(fake_intent_helper_instance_.get());
WaitForInstanceReady(
ArcServiceManager::Get()->arc_bridge_service()->intent_helper());
fake_backup_settings_instance_ =
std::make_unique<FakeBackupSettingsInstance>();
ArcServiceManager::Get()
->arc_bridge_service()
->backup_settings()
->SetInstance(fake_backup_settings_instance_.get());
WaitForInstanceReady(
ArcServiceManager::Get()->arc_bridge_service()->backup_settings());
}
void TearDownOnMainThread() override {
ArcServiceManager::Get()
->arc_bridge_service()
->backup_settings()
->SetInstance(nullptr);
fake_backup_settings_instance_.reset();
ArcServiceManager::Get()
->arc_bridge_service()
->intent_helper()
......@@ -301,6 +315,7 @@ class ArcSettingsServiceTest : public InProcessBrowserTest {
}
std::unique_ptr<FakeIntentHelperInstance> fake_intent_helper_instance_;
std::unique_ptr<FakeBackupSettingsInstance> fake_backup_settings_instance_;
private:
void SetupNetworkEnvironment() {
......@@ -337,7 +352,7 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, BackupRestorePolicyTest) {
prefs->SetBoolean(prefs::kArcBackupRestoreEnabled, true);
EXPECT_TRUE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled));
fake_intent_helper_instance_->clear_broadcasts();
fake_backup_settings_instance_->ClearCallHistory();
// The policy is set to false.
policy::PolicyMap policy;
......@@ -347,18 +362,15 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, BackupRestorePolicyTest) {
nullptr);
UpdatePolicy(policy);
// The pref is disabled and managed, and the corresponding broadcast is sent
// at least once.
// The pref is disabled and managed, and the corresponding sync method
// reflects the pref.
EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled));
EXPECT_TRUE(prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled));
base::DictionaryValue expected_broadcast_extras;
expected_broadcast_extras.SetBoolean("enabled", false);
expected_broadcast_extras.SetBoolean("managed", true);
EXPECT_GE(CountBroadcasts(fake_intent_helper_instance_->broadcasts(),
kBackupBroadcastAction, &expected_broadcast_extras),
1);
EXPECT_TRUE(fake_backup_settings_instance_->set_backup_enabled_called());
EXPECT_FALSE(fake_backup_settings_instance_->enabled());
EXPECT_TRUE(fake_backup_settings_instance_->managed());
fake_intent_helper_instance_->clear_broadcasts();
fake_backup_settings_instance_->ClearCallHistory();
// The policy is set to true.
policy.Set(policy::key::kArcBackupRestoreEnabled,
......@@ -367,30 +379,27 @@ IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, BackupRestorePolicyTest) {
nullptr);
UpdatePolicy(policy);
// The pref is enabled and managed, and the corresponding broadcast is sent at
// least once.
// The pref is enabled and managed, and the corresponding sync method
// reflects the pref.
EXPECT_TRUE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled));
EXPECT_TRUE(prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled));
expected_broadcast_extras.SetBoolean("enabled", true);
EXPECT_GE(CountBroadcasts(fake_intent_helper_instance_->broadcasts(),
kBackupBroadcastAction, &expected_broadcast_extras),
1);
EXPECT_TRUE(fake_backup_settings_instance_->set_backup_enabled_called());
EXPECT_TRUE(fake_backup_settings_instance_->enabled());
EXPECT_TRUE(fake_backup_settings_instance_->managed());
fake_intent_helper_instance_->clear_broadcasts();
fake_backup_settings_instance_->ClearCallHistory();
// The policy is unset.
policy.Erase(policy::key::kArcBackupRestoreEnabled);
UpdatePolicy(policy);
// The pref is disabled and unmanaged, and the corresponding broadcast is
// sent.
// The pref is disabled and unmanaged, and the corresponding sync method
// reflects the pref.
EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled));
EXPECT_FALSE(prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled));
expected_broadcast_extras.SetBoolean("enabled", false);
expected_broadcast_extras.SetBoolean("managed", false);
EXPECT_EQ(CountBroadcasts(fake_intent_helper_instance_->broadcasts(),
kBackupBroadcastAction, &expected_broadcast_extras),
1);
EXPECT_TRUE(fake_backup_settings_instance_->set_backup_enabled_called());
EXPECT_FALSE(fake_backup_settings_instance_->enabled());
EXPECT_FALSE(fake_backup_settings_instance_->managed());
}
IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, LocationServicePolicyTest) {
......
......@@ -167,6 +167,8 @@ static_library("arc_test_support") {
"test/fake_arc_bridge_host.h",
"test/fake_arc_session.cc",
"test/fake_arc_session.h",
"test/fake_backup_settings_instance.cc",
"test/fake_backup_settings_instance.h",
"test/fake_bluetooth_instance.cc",
"test/fake_bluetooth_instance.h",
"test/fake_file_system_instance.cc",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/arc/test/fake_backup_settings_instance.h"
namespace arc {
FakeBackupSettingsInstance::FakeBackupSettingsInstance() = default;
FakeBackupSettingsInstance::~FakeBackupSettingsInstance() = default;
void FakeBackupSettingsInstance::ClearCallHistory() {
set_backup_enabled_called_ = false;
}
void FakeBackupSettingsInstance::SetBackupEnabled(bool enabled, bool managed) {
set_backup_enabled_called_ = true;
enabled_ = enabled;
managed_ = managed;
}
} // namespace arc
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_ARC_TEST_FAKE_BACKUP_SETTINGS_INSTANCE_H_
#define COMPONENTS_ARC_TEST_FAKE_BACKUP_SETTINGS_INSTANCE_H_
#include "base/macros.h"
#include "components/arc/common/backup_settings.mojom.h"
namespace arc {
class FakeBackupSettingsInstance : public mojom::BackupSettingsInstance {
public:
FakeBackupSettingsInstance();
~FakeBackupSettingsInstance() override;
// mojom::BackupSettingsInstance overrides:
void SetBackupEnabled(bool enabled, bool managed) override;
void ClearCallHistory();
bool set_backup_enabled_called() const { return set_backup_enabled_called_; }
bool enabled() const { return enabled_; }
bool managed() const { return managed_; }
private:
bool set_backup_enabled_called_ = false;
bool enabled_ = false;
bool managed_ = false;
DISALLOW_COPY_AND_ASSIGN(FakeBackupSettingsInstance);
};
} // namespace arc
#endif // COMPONENTS_ARC_TEST_FAKE_BACKUP_SETTINGS_INSTANCE_H_
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