[modular] Add build flag auto_login_to_guest_user for skipping login.
- Also remove auto_login flag which is default behavior for all session
shells.
Usage: specify --args=auto_login_to_guest=true in fx set
MF-160 #done
TESTED: manual testing
Change-Id: I5dfcb7cb69c11bc48a8e4186a01d4db67b773898
diff --git a/bin/basemgr/BUILD.gn b/bin/basemgr/BUILD.gn
index 39b6b7c..b5c2834 100644
--- a/bin/basemgr/BUILD.gn
+++ b/bin/basemgr/BUILD.gn
@@ -2,10 +2,16 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/package.gni")
import("//peridot/build/executable_package.gni")
import("//peridot/build/tests_package.gni")
import("//third_party/flatbuffers/flatbuffer.gni")
+declare_args() {
+ # Whether basemgr should automatically login as a guest user.
+ auto_login_to_guest = false
+}
+
flatbuffer("users") {
sources = [
"users.fbs",
@@ -111,6 +117,10 @@
"//peridot/public/fidl/fuchsia.modular.internal",
"//zircon/public/lib/trace",
]
+
+ if (auto_login_to_guest) {
+ public_configs = [ ":auto_login_to_guest" ]
+ }
}
executable_package("dev_base_shell") {
@@ -157,3 +167,7 @@
"//third_party/googletest:gtest_main",
]
}
+
+config("auto_login_to_guest") {
+ defines = [ "AUTO_LOGIN_TO_GUEST" ]
+}
diff --git a/bin/basemgr/basemgr_impl.cc b/bin/basemgr/basemgr_impl.cc
index 51ed71e..4ec0aed 100644
--- a/bin/basemgr/basemgr_impl.cc
+++ b/bin/basemgr/basemgr_impl.cc
@@ -33,6 +33,14 @@
namespace modular {
+namespace {
+#ifdef AUTO_LOGIN_TO_GUEST
+constexpr bool kAutoLoginToGuest = true;
+#else
+constexpr bool kAutoLoginToGuest = false;
+#endif
+} // namespace
+
BasemgrImpl::BasemgrImpl(
const modular::BasemgrSettings& settings,
const std::vector<SessionShellSettings>& session_shell_settings,
@@ -460,11 +468,17 @@
void BasemgrImpl::ShowSetupOrLogin() {
auto show_setup_or_login = [this] {
- // If the session shell settings specifies it, auto-login as the first
- // authenticated user. Otherwise, start the base shell to launch setup.
- if (active_session_shell_settings_index_ < session_shell_settings_.size() &&
- session_shell_settings_[active_session_shell_settings_index_]
- .auto_login) {
+ // If there are no session shell settings specified, default to showing
+ // setup.
+ if (active_session_shell_settings_index_ >=
+ session_shell_settings_.size()) {
+ StartBaseShell();
+ return;
+ }
+
+ if (kAutoLoginToGuest) {
+ user_provider_impl_->Login(fuchsia::modular::UserLoginParams());
+ } else {
user_provider_impl_->PreviousUsers(
[this](fidl::VectorPtr<fuchsia::modular::auth::Account> accounts) {
if (accounts->empty()) {
@@ -475,8 +489,6 @@
user_provider_impl_->Login(std::move(params));
}
});
- } else {
- StartBaseShell();
}
};
diff --git a/lib/session_shell_settings/session_shell_settings.cc b/lib/session_shell_settings/session_shell_settings.cc
index 44ad687..4118697 100644
--- a/lib/session_shell_settings/session_shell_settings.cc
+++ b/lib/session_shell_settings/session_shell_settings.cc
@@ -137,8 +137,6 @@
.screen_height = GetObjectValue<float>(session_shell, "screen_height"),
.display_usage = GetObjectValue<fuchsia::ui::policy::DisplayUsage>(
session_shell, "display_usage"),
- .auto_login =
- GetObjectValue<std::string>(session_shell, "auto_login") == "true",
});
}
@@ -183,8 +181,7 @@
return false;
};
- return lhs.name == rhs.name && lhs.auto_login == rhs.auto_login &&
- float_eq(lhs.screen_width, rhs.screen_width) &&
+ return lhs.name == rhs.name && float_eq(lhs.screen_width, rhs.screen_width) &&
float_eq(lhs.screen_height, rhs.screen_height) &&
lhs.display_usage == rhs.display_usage;
}
diff --git a/lib/session_shell_settings/session_shell_settings.h b/lib/session_shell_settings/session_shell_settings.h
index a4206b1..2b7fce4 100644
--- a/lib/session_shell_settings/session_shell_settings.h
+++ b/lib/session_shell_settings/session_shell_settings.h
@@ -23,10 +23,6 @@
// The name of the session shell, e.g. "ermine".
const std::string name;
- // Whether the session shell should auto-login to the first authenticated
- // user.
- const bool auto_login;
-
// The screen width & height in millimeters for the session shell's display.
// Defaults to a signaling NaN so that any attempts to use it without checking
// for NaN will trap.