typecd: Determine DP-only mode entry from config
We've introduced a chromeos-config (typecd/mode-entry-dp-only) to denote
whether the system should only entry DP alternate mode. Use that to fill
out the stub function in CrosConfigUtil for the same.
BUG=b:230384036
TEST=- FEATURES=test emerge-brya chromeos-base/typecd passes.
- Test anahera both with and without this config and verify through
logs that it is processed correctly.
Change-Id: I084663bbaedfaa3b48b411c13b0e61da2bd9d7f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/3611075
Reviewed-by: Jameson Thies <jthies@google.com>
Tested-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Benson Leung <bleung@google.com>
Commit-Queue: YH Lin <yueherngl@chromium.org>
Auto-Submit: Prashant Malani <pmalani@chromium.org>
(cherry picked from commit b9240bf5314269f8055e0e7249560de2574d3f7d)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/3615820
Commit-Queue: Prashant Malani <pmalani@chromium.org>
diff --git a/typecd/cros_config_util.cc b/typecd/cros_config_util.cc
index 2d38a00..98e02eb 100644
--- a/typecd/cros_config_util.cc
+++ b/typecd/cros_config_util.cc
@@ -7,6 +7,7 @@
#include <string>
#include <base/logging.h>
+#include <base/strings/string_util.h>
namespace typecd {
@@ -16,7 +17,18 @@
}
bool CrosConfigUtil::APModeEntryDPOnly() {
- // TODO(b/230384036): Use an actual pref to fill this out.
+ std::string dp_only;
+ if (!config_->GetString("/typecd", "mode-entry-dp-only", &dp_only)) {
+ LOG(INFO) << "Can't access DP-only config; assuming USB4 support.";
+ return false;
+ }
+
+ base::TrimWhitespaceASCII(dp_only, base::TRIM_TRAILING, &dp_only);
+ if (dp_only == "true") {
+ LOG(INFO) << "Restricting AP-driven mode entry to DisplayPort only.";
+ return true;
+ }
+
return false;
}