Commit dad23679 authored by khmel@chromium.org's avatar khmel@chromium.org Committed by Commit Bot

arc: Preserve suppress Play Store show state.

This preserves suppress Play Store show state in case Chrome was
restarted during the previous session and initial OptIn flow is
currently active.

TEST=Locally, simulating that case  + unit test
BUG=b:119069366

Change-Id: Ifc30bf538baf42d6b91a20d8263d90e7d8962db2
Reviewed-on: https://chromium-review.googlesource.com/c/1331829Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Yury Khmel <khmel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608208}
parent 63f178ef
...@@ -337,12 +337,16 @@ void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) { ...@@ -337,12 +337,16 @@ void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
scoped_opt_in_tracker_.reset(); scoped_opt_in_tracker_.reset();
} }
if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) PrefService* const prefs = profile_->GetPrefs();
if (prefs->GetBoolean(prefs::kArcSignedIn))
return; return;
profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); prefs->SetBoolean(prefs::kArcSignedIn, true);
if (ShouldLaunchPlayStoreApp(profile_, oobe_or_assistant_wizard_start_)) { if (ShouldLaunchPlayStoreApp(
profile_,
prefs->GetBoolean(prefs::kArcProvisioningInitiatedFromOobe))) {
playstore_launcher_ = std::make_unique<ArcAppLauncher>( playstore_launcher_ = std::make_unique<ArcAppLauncher>(
profile_, kPlayStoreAppId, profile_, kPlayStoreAppId,
GetLaunchIntent(kPlayStorePackage, kPlayStoreActivity, GetLaunchIntent(kPlayStorePackage, kPlayStoreActivity,
...@@ -351,6 +355,8 @@ void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) { ...@@ -351,6 +355,8 @@ void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
arc::UserInteractionType::NOT_USER_INITIATED); arc::UserInteractionType::NOT_USER_INITIATED);
} }
prefs->ClearPref(prefs::kArcProvisioningInitiatedFromOobe);
for (auto& observer : observer_list_) for (auto& observer : observer_list_)
observer.OnArcInitialStart(); observer.OnArcInitialStart();
return; return;
...@@ -664,11 +670,22 @@ bool ArcSessionManager::RequestEnableImpl() { ...@@ -664,11 +670,22 @@ bool ArcSessionManager::RequestEnableImpl() {
return false; return false;
} }
oobe_or_assistant_wizard_start_ =
IsArcOobeOptInActive() || IsArcOptInWizardForAssistantActive();
PrefService* const prefs = profile_->GetPrefs(); PrefService* const prefs = profile_->GetPrefs();
// |prefs::kArcProvisioningInitiatedFromOobe| is used to remember
// |IsArcOobeOptInActive| or |IsArcOptInWizardForAssistantActive| state when
// ARC start request was made initially. |IsArcOobeOptInActive| or
// |IsArcOptInWizardForAssistantActive| will be changed by the time when
// decision to auto-launch the Play Store would be made.
// |IsArcOobeOptInActive| and |IsArcOptInWizardForAssistantActive| are not
// preserved on Chrome restart also and in last case
// |prefs::kArcProvisioningInitiatedFromOobe| is used to remember the state of
// the initial request.
// |prefs::kArcProvisioningInitiatedFromOobe| is reset when provisioning is
// done or ARC is opted out.
if (IsArcOobeOptInActive() || IsArcOptInWizardForAssistantActive())
prefs->SetBoolean(prefs::kArcProvisioningInitiatedFromOobe, true);
// If it is marked that sign in has been successfully done or if Play Store is // If it is marked that sign in has been successfully done or if Play Store is
// not available, then directly start ARC with skipping Play Store ToS. // not available, then directly start ARC with skipping Play Store ToS.
// For Kiosk mode, skip ToS because it is very likely that near the device // For Kiosk mode, skip ToS because it is very likely that near the device
...@@ -733,7 +750,6 @@ void ArcSessionManager::RequestDisable() { ...@@ -733,7 +750,6 @@ void ArcSessionManager::RequestDisable() {
return; return;
} }
oobe_or_assistant_wizard_start_ = false;
directly_started_ = false; directly_started_ = false;
enable_requested_ = false; enable_requested_ = false;
scoped_opt_in_tracker_.reset(); scoped_opt_in_tracker_.reset();
...@@ -845,6 +861,7 @@ void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) { ...@@ -845,6 +861,7 @@ void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) {
terms_of_service_negotiator_.reset(); terms_of_service_negotiator_.reset();
if (!accepted) { if (!accepted) {
VLOG(1) << "Terms of services declined";
// User does not accept the Terms of Service. Disable Google Play Store. // User does not accept the Terms of Service. Disable Google Play Store.
MaybeUpdateOptInCancelUMA(support_host_.get()); MaybeUpdateOptInCancelUMA(support_host_.get());
SetArcPlayStoreEnabledForProfile(profile_, false); SetArcPlayStoreEnabledForProfile(profile_, false);
...@@ -852,6 +869,7 @@ void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) { ...@@ -852,6 +869,7 @@ void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) {
} }
// Terms were accepted. // Terms were accepted.
VLOG(1) << "Terms of services accepted";
profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true);
StartAndroidManagementCheck(); StartAndroidManagementCheck();
} }
...@@ -1016,6 +1034,8 @@ void ArcSessionManager::StopArc() { ...@@ -1016,6 +1034,8 @@ void ArcSessionManager::StopArc() {
profile_->GetPrefs()->SetBoolean(prefs::kArcPaiStarted, false); profile_->GetPrefs()->SetBoolean(prefs::kArcPaiStarted, false);
profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, false); profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, false);
profile_->GetPrefs()->SetBoolean(prefs::kArcFastAppReinstallStarted, false); profile_->GetPrefs()->SetBoolean(prefs::kArcFastAppReinstallStarted, false);
profile_->GetPrefs()->SetBoolean(prefs::kArcProvisioningInitiatedFromOobe,
false);
} }
ShutdownSession(); ShutdownSession();
......
...@@ -365,13 +365,6 @@ class ArcSessionManager : public ArcSessionRunner::Observer, ...@@ -365,13 +365,6 @@ class ArcSessionManager : public ArcSessionRunner::Observer,
std::unique_ptr<ArcAppLauncher> playstore_launcher_; std::unique_ptr<ArcAppLauncher> playstore_launcher_;
bool reenable_arc_ = false; bool reenable_arc_ = false;
bool provisioning_reported_ = false; bool provisioning_reported_ = false;
// In case ARC is started from OOBE |oobe_start_|, set to true. This flag is
// used to remember |IsArcOobeOptInActive| or
// |IsArcOptInWizardForAssistantActive| state when ARC start request was made.
// |IsArcOobeOptInActive| or |IsArcOptInWizardForAssistantActive| will be
// changed by the time when |oobe_or_opa_start_| is checked to prevent the
// Play Store auto-launch.
bool oobe_or_assistant_wizard_start_ = false;
bool directly_started_ = false; bool directly_started_ = false;
base::OneShotTimer arc_sign_in_timer_; base::OneShotTimer arc_sign_in_timer_;
......
...@@ -492,6 +492,55 @@ TEST_F(ArcSessionManagerTest, Provisioning_Success) { ...@@ -492,6 +492,55 @@ TEST_F(ArcSessionManagerTest, Provisioning_Success) {
EXPECT_TRUE(arc_session_manager()->IsPlaystoreLaunchRequestedForTesting()); EXPECT_TRUE(arc_session_manager()->IsPlaystoreLaunchRequestedForTesting());
} }
// Verifies that Play Store shown is suppressed on restart when required.
TEST_F(ArcSessionManagerTest, PlayStoreSuppressed) {
// Set up the situation that terms were accepted in the previous session.
PrefService* const prefs = profile()->GetPrefs();
prefs->SetBoolean(prefs::kArcTermsAccepted, true);
// Set the flag indicating that the provisioning was initiated from OOBE in
// the previous session.
prefs->SetBoolean(prefs::kArcProvisioningInitiatedFromOobe, true);
arc_session_manager()->SetProfile(profile());
arc_session_manager()->Initialize();
arc_session_manager()->RequestEnable();
arc_session_manager()->StartArcForTesting();
// Second start, no fetching code is expected.
EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
EXPECT_FALSE(arc_session_manager()->IsPlaystoreLaunchRequestedForTesting());
arc_session_manager()->OnProvisioningFinished(ProvisioningResult::SUCCESS);
// Completing the provisioning resets this flag.
EXPECT_FALSE(prefs->GetBoolean(prefs::kArcProvisioningInitiatedFromOobe));
EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
// |prefs::kArcProvisioningInitiatedFromOobe| flag prevents opening the
// Play Store.
EXPECT_FALSE(arc_session_manager()->IsPlaystoreLaunchRequestedForTesting());
// Correctly stop service.
arc_session_manager()->Shutdown();
}
TEST_F(ArcSessionManagerTest, InitiatedFromOobeIsResetOnOptOut) {
// Set up the situation that terms were accepted in the previous session.
PrefService* const prefs = profile()->GetPrefs();
prefs->SetBoolean(prefs::kArcTermsAccepted, true);
// Set the flag indicating that the provisioning was initiated from OOBE in
// the previous session.
prefs->SetBoolean(prefs::kArcProvisioningInitiatedFromOobe, true);
arc_session_manager()->SetProfile(profile());
arc_session_manager()->Initialize();
arc_session_manager()->RequestEnable();
EXPECT_TRUE(prefs->GetBoolean(prefs::kArcProvisioningInitiatedFromOobe));
// Disabling ARC resets suppress state
arc_session_manager()->RequestDisable();
EXPECT_FALSE(prefs->GetBoolean(prefs::kArcProvisioningInitiatedFromOobe));
// Correctly stop service.
arc_session_manager()->Shutdown();
}
TEST_F(ArcSessionManagerTest, Provisioning_Restart) { TEST_F(ArcSessionManagerTest, Provisioning_Restart) {
// Set up the situation that provisioning is successfully done in the // Set up the situation that provisioning is successfully done in the
// previous session. // previous session.
......
...@@ -60,6 +60,10 @@ const char kArcLocationServiceEnabled[] = "arc.location_service.enabled"; ...@@ -60,6 +60,10 @@ const char kArcLocationServiceEnabled[] = "arc.location_service.enabled";
const char kArcPackages[] = "arc.packages"; const char kArcPackages[] = "arc.packages";
// A preference that indicates that Play Auto Install flow was already started. // A preference that indicates that Play Auto Install flow was already started.
const char kArcPaiStarted[] = "arc.pai.started"; const char kArcPaiStarted[] = "arc.pai.started";
// A preference that indicates that provisioning was initiated from OOBE. This
// is preserved across Chrome restart.
const char kArcProvisioningInitiatedFromOobe[] =
"arc.provisioning.initiated.from.oobe";
// A preference that indicates that Play Fast App Reinstall flow was already // A preference that indicates that Play Fast App Reinstall flow was already
// started. // started.
const char kArcFastAppReinstallStarted[] = "arc.fast.app.reinstall.started"; const char kArcFastAppReinstallStarted[] = "arc.fast.app.reinstall.started";
...@@ -147,6 +151,7 @@ void RegisterProfilePrefs(PrefRegistrySimple* registry) { ...@@ -147,6 +151,7 @@ void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(kArcFastAppReinstallStarted, false); registry->RegisterBooleanPref(kArcFastAppReinstallStarted, false);
registry->RegisterListPref(kArcFastAppReinstallPackages); registry->RegisterListPref(kArcFastAppReinstallPackages);
registry->RegisterBooleanPref(kArcPolicyComplianceReported, false); registry->RegisterBooleanPref(kArcPolicyComplianceReported, false);
registry->RegisterBooleanPref(kArcProvisioningInitiatedFromOobe, false);
registry->RegisterBooleanPref(kArcSignedIn, false); registry->RegisterBooleanPref(kArcSignedIn, false);
registry->RegisterBooleanPref(kArcSkippedReportingNotice, false); registry->RegisterBooleanPref(kArcSkippedReportingNotice, false);
registry->RegisterBooleanPref(kArcTermsAccepted, false); registry->RegisterBooleanPref(kArcTermsAccepted, false);
......
...@@ -29,6 +29,7 @@ ARC_EXPORT extern const char kArcTermsShownInOobe[]; ...@@ -29,6 +29,7 @@ ARC_EXPORT extern const char kArcTermsShownInOobe[];
ARC_EXPORT extern const char kArcLocationServiceEnabled[]; ARC_EXPORT extern const char kArcLocationServiceEnabled[];
ARC_EXPORT extern const char kArcPackages[]; ARC_EXPORT extern const char kArcPackages[];
ARC_EXPORT extern const char kArcPaiStarted[]; ARC_EXPORT extern const char kArcPaiStarted[];
ARC_EXPORT extern const char kArcProvisioningInitiatedFromOobe[];
ARC_EXPORT extern const char kArcPushInstallAppsRequested[]; ARC_EXPORT extern const char kArcPushInstallAppsRequested[];
ARC_EXPORT extern const char kArcPushInstallAppsPending[]; ARC_EXPORT extern const char kArcPushInstallAppsPending[];
ARC_EXPORT extern const char kArcSetNotificationsEnabledDeferred[]; ARC_EXPORT extern const char kArcSetNotificationsEnabledDeferred[];
......
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