Replaced boolean flag with an integral flag

Currently, we only track whether or not consent has been given to access
a user's Web and App activity in Assistant. We do the tracking using a
boolean preference flag. However, due to the need to handle the various
consent error states, we need to replace the boolean flag with an
integral one.

The work in this CL is needed to provide a separate experience for
GSuite users whose administrators have not granted access to Web &
App activity.

Design: go/gsuite-optin
Bug: b:123638794
Change-Id: I4bfbde8b90b9b560ef2f6e29721e655051ad111d
Reviewed-on: https://chromium-review.googlesource.com/c/1446779
Reviewed-by: Yusuke Sato <[email protected]>
Reviewed-by: Hidehiko Abe <[email protected]>
Reviewed-by: Dan Beam <[email protected]>
Reviewed-by: Dominic Battré <[email protected]>
Reviewed-by: Xiaohui Chen <[email protected]>
Reviewed-by: Xiyuan Xia <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: Eyor Alemayehu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#633853}
diff --git a/chrome/browser/chromeos/arc/voice_interaction/fake_voice_interaction_controller.cc b/chrome/browser/chromeos/arc/voice_interaction/fake_voice_interaction_controller.cc
index 295b6c4..1280a28 100644
--- a/chrome/browser/chromeos/arc/voice_interaction/fake_voice_interaction_controller.cc
+++ b/chrome/browser/chromeos/arc/voice_interaction/fake_voice_interaction_controller.cc
@@ -39,8 +39,9 @@
   voice_interaction_hotword_enabled_ = enabled;
 }
 
-void FakeVoiceInteractionController::NotifySetupCompleted(bool completed) {
-  voice_interaction_setup_completed_ = completed;
+void FakeVoiceInteractionController::NotifyConsentStatus(
+    ash::mojom::ConsentStatus consent_status) {
+  consent_status_ = consent_status;
 }
 
 void FakeVoiceInteractionController::NotifyFeatureAllowed(
diff --git a/chrome/browser/chromeos/arc/voice_interaction/fake_voice_interaction_controller.h b/chrome/browser/chromeos/arc/voice_interaction/fake_voice_interaction_controller.h
index a14b993..36a4228 100644
--- a/chrome/browser/chromeos/arc/voice_interaction/fake_voice_interaction_controller.h
+++ b/chrome/browser/chromeos/arc/voice_interaction/fake_voice_interaction_controller.h
@@ -26,7 +26,7 @@
   void NotifyContextEnabled(bool enabled) override;
   void NotifyHotwordAlwaysOn(bool enabled) override;
   void NotifyHotwordEnabled(bool enabled) override;
-  void NotifySetupCompleted(bool completed) override;
+  void NotifyConsentStatus(ash::mojom::ConsentStatus consent_status) override;
   void NotifyFeatureAllowed(ash::mojom::AssistantAllowedState state) override;
   void NotifyNotificationEnabled(bool enabled) override;
   void NotifyLocaleChanged(const std::string& locale) override;
@@ -45,8 +45,8 @@
   bool voice_interaction_hotword_enabled() const {
     return voice_interaction_hotword_enabled_;
   }
-  bool voice_interaction_setup_completed() const {
-    return voice_interaction_setup_completed_;
+  ash::mojom::ConsentStatus voice_interaction_consent_status() const {
+    return consent_status_;
   }
   ash::mojom::AssistantAllowedState assistant_allowed_state() const {
     return assistant_allowed_state_;
@@ -64,7 +64,8 @@
   bool voice_interaction_context_enabled_ = false;
   bool voice_interaction_hotword_always_on_ = false;
   bool voice_interaction_hotword_enabled_ = false;
-  bool voice_interaction_setup_completed_ = false;
+  ash::mojom::ConsentStatus consent_status_ =
+      ash::mojom::ConsentStatus::kUnknown;
   bool voice_interaction_notification_enabled_ = false;
   std::string locale_;
   ash::mojom::AssistantAllowedState assistant_allowed_state_ =
diff --git a/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.cc b/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.cc
index 834b6b0..98156d9 100644
--- a/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.cc
+++ b/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.cc
@@ -14,6 +14,7 @@
 #include "chrome/browser/chromeos/arc/arc_util.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/ash/assistant/assistant_pref_util.h"
 #include "chromeos/constants/chromeos_switches.h"
 #include "components/arc/arc_prefs.h"
 #include "components/arc/arc_util.h"
@@ -116,12 +117,11 @@
   voice_interaction_controller_->NotifyHotwordAlwaysOn(always_on);
 }
 
-void VoiceInteractionControllerClient::NotifySetupCompleted() {
+void VoiceInteractionControllerClient::NotifyConsentStatus() {
   DCHECK(profile_);
   PrefService* prefs = profile_->GetPrefs();
-  bool completed =
-      prefs->GetBoolean(prefs::kVoiceInteractionActivityControlAccepted);
-  voice_interaction_controller_->NotifySetupCompleted(completed);
+  voice_interaction_controller_->NotifyConsentStatus(
+      assistant::prefs::GetConsentStatus(prefs));
 }
 
 void VoiceInteractionControllerClient::NotifyFeatureAllowed() {
@@ -182,9 +182,9 @@
   pref_change_registrar_->Init(prefs);
 
   pref_change_registrar_->Add(
-      prefs::kVoiceInteractionActivityControlAccepted,
+      assistant::prefs::kAssistantConsentStatus,
       base::BindRepeating(
-          &VoiceInteractionControllerClient::NotifySetupCompleted,
+          &VoiceInteractionControllerClient::NotifyConsentStatus,
           base::Unretained(this)));
   pref_change_registrar_->Add(
       language::prefs::kApplicationLocale,
@@ -222,7 +222,7 @@
           &VoiceInteractionControllerClient::NotifyLaunchWithMicOpen,
           base::Unretained(this)));
 
-  NotifySetupCompleted();
+  NotifyConsentStatus();
   NotifySettingsEnabled();
   NotifyContextEnabled();
   NotifyLocaleChanged();
diff --git a/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.h b/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.h
index 008ce13..7e64737 100644
--- a/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.h
+++ b/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.h
@@ -56,7 +56,7 @@
   void NotifyContextEnabled();
   void NotifyHotwordEnabled();
   void NotifyHotwordAlwaysOn();
-  void NotifySetupCompleted();
+  void NotifyConsentStatus();
   void NotifyFeatureAllowed();
   void NotifyNotificationEnabled();
   void NotifyLocaleChanged();
diff --git a/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client_unittest.cc b/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client_unittest.cc
index 5d428d1..5e658eb 100644
--- a/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client_unittest.cc
+++ b/chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client_unittest.cc
@@ -10,6 +10,7 @@
 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
 #include "chrome/browser/chromeos/arc/voice_interaction/fake_voice_interaction_controller.h"
 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
+#include "chrome/browser/ui/ash/assistant/assistant_pref_util.h"
 #include "chrome/test/base/chrome_ash_test_base.h"
 #include "chrome/test/base/testing_profile.h"
 #include "components/arc/arc_prefs.h"
@@ -138,15 +139,17 @@
       false,
       voice_interaction_controller()->voice_interaction_notification_enabled());
 
-  ASSERT_EQ(false,
-            prefs->GetBoolean(prefs::kVoiceInteractionActivityControlAccepted));
-  prefs->SetBoolean(prefs::kVoiceInteractionActivityControlAccepted, true);
-  ASSERT_EQ(true,
-            prefs->GetBoolean(prefs::kVoiceInteractionActivityControlAccepted));
+  ASSERT_EQ(static_cast<int>(ash::mojom::ConsentStatus::kUnknown),
+            prefs->GetInteger(assistant::prefs::kAssistantConsentStatus));
+  prefs->SetInteger(
+      assistant::prefs::kAssistantConsentStatus,
+      static_cast<int>(ash::mojom::ConsentStatus::kActivityControlAccepted));
+  ASSERT_EQ(
+      static_cast<int>(ash::mojom::ConsentStatus::kActivityControlAccepted),
+      prefs->GetInteger(assistant::prefs::kAssistantConsentStatus));
   voice_interaction_controller_client()->FlushMojoForTesting();
-  EXPECT_EQ(
-      true,
-      voice_interaction_controller()->voice_interaction_setup_completed());
+  EXPECT_EQ(ash::mojom::ConsentStatus::kActivityControlAccepted,
+            voice_interaction_controller()->voice_interaction_consent_status());
 
   ASSERT_EQ("", prefs->GetString(language::prefs::kApplicationLocale));
   prefs->SetString(language::prefs::kApplicationLocale, "en-CA");
diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chrome/browser/extensions/api/settings_private/prefs_util.cc
index 2b804c2..f28d285 100644
--- a/chrome/browser/extensions/api/settings_private/prefs_util.cc
+++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc
@@ -52,6 +52,7 @@
 #include "chrome/browser/chromeos/system/timezone_util.h"
 #include "chrome/browser/extensions/api/settings_private/chromeos_resolve_time_zone_by_geolocation_method_short.h"
 #include "chrome/browser/extensions/api/settings_private/chromeos_resolve_time_zone_by_geolocation_on_off.h"
+#include "chrome/browser/ui/ash/assistant/assistant_pref_util.h"
 #include "chromeos/constants/chromeos_features.h"
 #include "chromeos/settings/cros_settings_names.h"
 #include "components/arc/arc_prefs.h"
@@ -380,8 +381,8 @@
       settings_api::PrefType::PREF_TYPE_BOOLEAN;
 
   // Google Assistant.
-  (*s_whitelist)[arc::prefs::kVoiceInteractionActivityControlAccepted] =
-      settings_api::PrefType::PREF_TYPE_BOOLEAN;
+  (*s_whitelist)[::assistant::prefs::kAssistantConsentStatus] =
+      settings_api::PrefType::PREF_TYPE_NUMBER;
   (*s_whitelist)[arc::prefs::kVoiceInteractionEnabled] =
       settings_api::PrefType::PREF_TYPE_BOOLEAN;
   (*s_whitelist)[arc::prefs::kVoiceInteractionContextEnabled] =
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index d193b20..3a14537 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -286,6 +286,7 @@
 #include "chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h"
 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
+#include "chromeos/assistant/buildflags.h"
 #include "chromeos/audio/audio_devices_pref_handler_impl.h"
 #include "chromeos/constants/chromeos_switches.h"
 #include "chromeos/network/fast_transition_observer.h"
@@ -297,6 +298,11 @@
 #include "components/onc/onc_pref_names.h"
 #include "components/quirks/quirks_manager.h"
 #include "extensions/browser/api/lock_screen_data/lock_screen_item_storage.h"
+
+#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
+#include "chrome/browser/ui/ash/assistant/assistant_pref_util.h"
+#endif
+
 #else
 #include "chrome/browser/extensions/default_apps.h"
 #endif
@@ -394,6 +400,10 @@
 const char kNextUpdateCheck[] = "extensions.autoupdate.next_check";
 const char kLastUpdateCheck[] = "extensions.autoupdate.last_check";
 
+// Deprecated 2/2019.
+const char kVoiceInteractionActivityControlAcceptedDeprecated[] =
+    "settings.voice_interaction.activity_control.accepted";
+
 // Register prefs used only for migration (clearing or moving to a new key).
 void RegisterProfilePrefsForMigration(
     user_prefs::PrefRegistrySyncable* registry) {
@@ -423,6 +433,9 @@
                                    PrefRegistry::LOSSY_PREF);
   registry->RegisterIntegerPref(kLastUpdateCheck, 0);
   registry->RegisterIntegerPref(kNextUpdateCheck, 0);
+
+  registry->RegisterBooleanPref(
+      kVoiceInteractionActivityControlAcceptedDeprecated, false);
 }
 
 }  // namespace
@@ -760,6 +773,11 @@
   policy::AppInstallEventLogManagerWrapper::RegisterProfilePrefs(registry);
   policy::DeviceStatusCollector::RegisterProfilePrefs(registry);
   ::onc::RegisterProfilePrefs(registry);
+
+#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
+  assistant::prefs::RegisterProfilePrefs(registry);
+#endif
+
 #endif
 
 #if defined(OS_CHROMEOS) && BUILDFLAG(ENABLE_APP_LIST)
@@ -834,6 +852,29 @@
 void RegisterLoginProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
   RegisterProfilePrefs(registry);
 }
+
+#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
+
+bool MigrateVoiceInteractionActivityControlAccepted(
+    PrefService* profile_prefs) {
+  const base::Value* activity_control_accepted =
+      profile_prefs->GetUserPrefValue(
+          kVoiceInteractionActivityControlAcceptedDeprecated);
+
+  if (!activity_control_accepted)
+    return false;
+
+  ash::mojom::ConsentStatus consent_status =
+      activity_control_accepted->GetBool()
+          ? ash::mojom::ConsentStatus::kActivityControlAccepted
+          : ash::mojom::ConsentStatus::kUnknown;
+
+  assistant::prefs::SetConsentStatus(profile_prefs, consent_status);
+  return true;
+}
+
+#endif
+
 #endif
 
 // This method should be periodically pruned of year+ old migrations.
@@ -908,11 +949,21 @@
 #if defined(OS_CHROMEOS)
   // Added 12/2018.
   profile_prefs->ClearPref(prefs::kDataSaverPromptsShown);
+
+#if BUILDFLAG(ENABLE_CROS_ASSISTANT)
+  // Added 2/2019.
+  if (MigrateVoiceInteractionActivityControlAccepted(profile_prefs)) {
+    profile_prefs->ClearPref(
+        kVoiceInteractionActivityControlAcceptedDeprecated);
+  }
+#endif
+
 #endif
 
   // Added 1/2019.
   profile_prefs->ClearPref(kLastUpdateCheck);
   profile_prefs->ClearPref(kNextUpdateCheck);
+
   syncer::MigrateSessionsToProxyTabsPrefs(profile_prefs);
   syncer::ClearObsoleteUserTypePrefs(profile_prefs);
 
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
index 0c6eace3..1506939 100644
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -3371,6 +3371,8 @@
       "ash/assistant/assistant_context_util.h",
       "ash/assistant/assistant_image_downloader.cc",
       "ash/assistant/assistant_image_downloader.h",
+      "ash/assistant/assistant_pref_util.cc",
+      "ash/assistant/assistant_pref_util.h",
       "ash/assistant/assistant_setup.cc",
       "ash/assistant/assistant_setup.h",
       "ash/assistant/device_actions.cc",
diff --git a/chrome/browser/ui/ash/assistant/assistant_pref_util.cc b/chrome/browser/ui/ash/assistant/assistant_pref_util.cc
new file mode 100644
index 0000000..127a63a6c
--- /dev/null
+++ b/chrome/browser/ui/ash/assistant/assistant_pref_util.cc
@@ -0,0 +1,36 @@
+// Copyright 2019 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 "chrome/browser/ui/ash/assistant/assistant_pref_util.h"
+
+#include <string>
+
+#include "components/arc/arc_prefs.h"
+#include "components/prefs/pref_registry_simple.h"
+
+namespace assistant {
+namespace prefs {
+
+const char kAssistantConsentStatus[] =
+    "settings.voice_interaction.activity_control.consent_status";
+
+void RegisterProfilePrefs(PrefRegistrySimple* registry) {
+  registry->RegisterIntegerPref(
+      kAssistantConsentStatus,
+      static_cast<int>(ash::mojom::ConsentStatus::kUnknown));
+}
+
+ash::mojom::ConsentStatus GetConsentStatus(PrefService* pref_service) {
+  return static_cast<ash::mojom::ConsentStatus>(
+      pref_service->GetInteger(kAssistantConsentStatus));
+}
+
+void SetConsentStatus(PrefService* pref_service,
+                      ash::mojom::ConsentStatus consent_status) {
+  pref_service->SetInteger(kAssistantConsentStatus,
+                           static_cast<int>(consent_status));
+}
+
+}  // namespace prefs
+}  // namespace assistant
diff --git a/chrome/browser/ui/ash/assistant/assistant_pref_util.h b/chrome/browser/ui/ash/assistant/assistant_pref_util.h
new file mode 100644
index 0000000..77ef30d
--- /dev/null
+++ b/chrome/browser/ui/ash/assistant/assistant_pref_util.h
@@ -0,0 +1,31 @@
+// Copyright 2019 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 CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_PREF_UTIL_H_
+#define CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_PREF_UTIL_H_
+
+#include "ash/public/interfaces/voice_interaction_controller.mojom.h"
+#include "components/prefs/pref_service.h"
+
+class PrefRegistrySimple;
+
+namespace assistant {
+namespace prefs {
+
+extern const char kAssistantConsentStatus[];
+
+// Registers Assistant specific profile preferences.
+void RegisterProfilePrefs(PrefRegistrySimple* registry);
+
+// Gets the user's consent status from the given preference service.
+ash::mojom::ConsentStatus GetConsentStatus(PrefService* pref_service);
+
+// Sets the user's consent status in the given preference service.
+void SetConsentStatus(PrefService* pref_service,
+                      ash::mojom::ConsentStatus consent_status);
+
+}  // namespace prefs
+}  // namespace assistant
+
+#endif  // CHROME_BROWSER_UI_ASH_ASSISTANT_ASSISTANT_PREF_UTIL_H_
diff --git a/chrome/browser/ui/ash/assistant/assistant_setup.cc b/chrome/browser/ui/ash/assistant/assistant_setup.cc
index 68f5ed5..cee0021 100644
--- a/chrome/browser/ui/ash/assistant/assistant_setup.cc
+++ b/chrome/browser/ui/ash/assistant/assistant_setup.cc
@@ -20,6 +20,7 @@
 #include "chrome/browser/notifications/notification_display_service.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/ash/assistant/assistant_pref_util.h"
 #include "chrome/browser/ui/chrome_pages.h"
 #include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h"
 #include "chrome/grit/generated_resources.h"
@@ -188,29 +189,25 @@
     case ConsentFlowUi::ASK_FOR_CONSENT:
       if (consent_ui.has_activity_control_ui() &&
           consent_ui.activity_control_ui().setting_zippy().size()) {
-        prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
-                          false);
+        assistant::prefs::SetConsentStatus(
+            prefs, ash::mojom::ConsentStatus::kNotFound);
       } else {
-        prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
-                          true);
+        assistant::prefs::SetConsentStatus(
+            prefs, ash::mojom::ConsentStatus::kActivityControlAccepted);
       }
       break;
     case ConsentFlowUi::ERROR_ACCOUNT:
-      // Show the opted out mode UI for unsupported Account as they are in opted
-      // out mode.
-      // TODO(llin): we should show a error account message in Opted out UI or
-      // in the onboarding flow.
-      prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
-                        false);
+      assistant::prefs::SetConsentStatus(
+          prefs, ash::mojom::ConsentStatus::kUnauthorized);
       break;
     case ConsentFlowUi::ALREADY_CONSENTED:
-      prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
-                        true);
+      assistant::prefs::SetConsentStatus(
+          prefs, ash::mojom::ConsentStatus::kActivityControlAccepted);
       break;
     case ConsentFlowUi::UNSPECIFIED:
     case ConsentFlowUi::ERROR:
-      prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
-                        false);
+      assistant::prefs::SetConsentStatus(prefs,
+                                         ash::mojom::ConsentStatus::kUnknown);
       LOG(ERROR) << "Invalid activity control consent status.";
   }
 }
@@ -219,7 +216,7 @@
   auto* pref_service = ProfileManager::GetActiveUserProfile()->GetPrefs();
   DCHECK(pref_service);
   if (!pref_service->GetUserPrefValue(
-          arc::prefs::kVoiceInteractionActivityControlAccepted)) {
+          assistant::prefs::kAssistantConsentStatus)) {
     base::SequencedTaskRunnerHandle::Get()->PostTask(
         FROM_HERE, base::BindOnce(&AssistantSetup::StartAssistantOptInFlow,
                                   weak_factory_.GetWeakPtr(),
diff --git a/chrome/browser/ui/ash/assistant/assistant_setup.h b/chrome/browser/ui/ash/assistant/assistant_setup.h
index 1a16670b..bc665d5 100644
--- a/chrome/browser/ui/ash/assistant/assistant_setup.h
+++ b/chrome/browser/ui/ash/assistant/assistant_setup.h
@@ -28,7 +28,7 @@
       ash::mojom::FlowType type,
       StartAssistantOptInFlowCallback callback) override;
 
-  // If prefs::kVoiceInteractionActivityControlAccepted is nullptr, means the
+  // If prefs::kVoiceInteractionConsentStatus is nullptr, means the
   // pref is not set by user. Therefore we need to start OOBE.
   void MaybeStartAssistantOptInFlow();
 
diff --git a/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc b/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
index 382b4a25..c06cf2b 100644
--- a/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
@@ -13,6 +13,7 @@
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/profiles/profile_manager.h"
 #include "chrome/browser/ui/ash/ash_util.h"
+#include "chrome/browser/ui/ash/assistant/assistant_pref_util.h"
 #include "chrome/browser/ui/views/chrome_web_dialog_view.h"
 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
 #include "chrome/common/url_constants.h"
@@ -149,7 +150,8 @@
   PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
   const bool completed =
       prefs->GetBoolean(arc::prefs::kVoiceInteractionEnabled) &&
-      prefs->GetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted);
+      (::assistant::prefs::GetConsentStatus(prefs) ==
+       ash::mojom::ConsentStatus::kActivityControlAccepted);
   std::move(callback_).Run(completed);
   SystemWebDialogDelegate::OnDialogClosed(json_retval);
 }
diff --git a/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc
index 58821e2..fa78c67 100644
--- a/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc
@@ -14,6 +14,7 @@
 #include "chrome/browser/chromeos/login/screens/assistant_optin_flow_screen.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/ash/assistant/assistant_pref_util.h"
 #include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
 #include "chrome/grit/generated_resources.h"
 #include "chromeos/services/assistant/public/features.h"
@@ -216,8 +217,8 @@
             weak_factory_.GetWeakPtr()));
   } else {
     RecordAssistantOptInStatus(ACTIVITY_CONTROL_SKIPPED);
-    profile->GetPrefs()->SetBoolean(
-        arc::prefs::kVoiceInteractionActivityControlAccepted, false);
+    ::assistant::prefs::SetConsentStatus(profile->GetPrefs(),
+                                         ash::mojom::ConsentStatus::kUnknown);
     HandleFlowFinished();
   }
 }
@@ -314,12 +315,17 @@
     // No need to consent. Move to the next screen.
     activity_control_needed_ = false;
     PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
-    prefs->SetBoolean(
-        arc::prefs::kVoiceInteractionActivityControlAccepted,
-        (settings_ui.consent_flow_ui().consent_status() ==
-             assistant::ConsentFlowUi_ConsentStatus_ALREADY_CONSENTED ||
-         settings_ui.consent_flow_ui().consent_status() ==
-             assistant::ConsentFlowUi_ConsentStatus_ASK_FOR_CONSENT));
+
+    bool consented =
+        settings_ui.consent_flow_ui().consent_status() ==
+            assistant::ConsentFlowUi_ConsentStatus_ALREADY_CONSENTED ||
+        settings_ui.consent_flow_ui().consent_status() ==
+            assistant::ConsentFlowUi_ConsentStatus_ASK_FOR_CONSENT;
+
+    ::assistant::prefs::SetConsentStatus(
+        prefs, consented ? ash::mojom::ConsentStatus::kActivityControlAccepted
+                         : ash::mojom::ConsentStatus::kUnknown);
+
     // Skip activity control and users will be in opted out mode.
     ShowNextScreen();
   } else {
@@ -380,8 +386,8 @@
     } else if (activity_control_needed_) {
       activity_control_needed_ = false;
       PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
-      prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
-                        true);
+      ::assistant::prefs::SetConsentStatus(
+          prefs, ash::mojom::ConsentStatus::kActivityControlAccepted);
     }
   }