Snap for 11164065 from bb30fa3297cbd71e0086d20a1740359641def129 to mainline-cellbroadcast-release

Change-Id: I46acf67fbbdd61f2026e07dad5b855b9cb148c1b
diff --git a/TEST_MAPPING b/TEST_MAPPING
index f711b63..fadf79d 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -28,6 +28,15 @@
     },
     {
       "name": "CtsScopedStorageDeviceOnlyTest"
+    },
+    {
+      "name": "CtsScopedStorageBypassDatabaseOperationsTest"
+    },
+    {
+      "name": "CtsScopedStorageGeneralTest"
+    },
+    {
+      "name": "CtsScopedStorageRedactUriTest"
     }
   ],
   "auto-presubmit": [
diff --git a/host/libs/config/config_flag.cpp b/host/libs/config/config_flag.cpp
index d4d5157..63afd23 100644
--- a/host/libs/config/config_flag.cpp
+++ b/host/libs/config/config_flag.cpp
@@ -16,6 +16,7 @@
 
 #include "host/libs/config/config_flag.h"
 
+#include <android-base/file.h>
 #include <android-base/logging.h>
 #include <android-base/strings.h>
 #include <gflags/gflags.h>
@@ -34,6 +35,8 @@
 DEFINE_string(system_image_dir, CF_DEFAULTS_SYSTEM_IMAGE_DIR, "");
 
 using gflags::FlagSettingMode::SET_FLAGS_DEFAULT;
+using android::base::ReadFileToString;
+using android::base::Split;
 
 namespace cuttlefish {
 
@@ -192,22 +195,36 @@
     if (!FileExists(info_path)) {
       return {};
     }
-    std::ifstream ifs{info_path};
-    if (!ifs.is_open()) {
-      return {};
-    }
     std::string android_info;
-    ifs >> android_info;
-    std::string_view local_android_info(android_info);
-    if (!android::base::ConsumePrefix(&local_android_info, "config=")) {
+    if(!ReadFileToString(info_path, &android_info)) {
       return {};
     }
-    if (!config_reader_.HasConfig(std::string{local_android_info})) {
+    // grab the last value of config in android-info.txt,
+    // it's the setting that's respected.
+    // TODO (rammuthiah) Replace this logic with ParseMiscInfo
+    // from host/commands/assemble_cvd/misc_info.h
+    // Currently blocked on linking error for misc_info which is part of
+    // assemble_cvd and this bit of code which is in run_cvd.
+    size_t config_idx = android_info.rfind("config=");
+    if (config_idx == std::string::npos) {
+      return {};
+    }
+    std::string config_value = android_info.substr(config_idx);
+    std::string_view local_config_value(config_value);
+    if (!android::base::ConsumePrefix(&local_config_value, "config=")) {
+      return {};
+    }
+    auto split_config = Split(std::string{local_config_value},"\n");
+    if (split_config.empty()) {
+      return {};
+    }
+    config_value = split_config[0];
+    if (!config_reader_.HasConfig(config_value)) {
       LOG(WARNING) << info_path << " contains invalid config preset: '"
-                   << local_android_info << "'.";
+                   << config_value << "'.";
       return {};
     }
-    return std::string{local_android_info};
+    return config_value;
   }
 
   ConfigReader& config_reader_;
diff --git a/shared/auto/android-info.txt b/shared/auto/android-info.txt
index cc15c01..74c0e2e 100644
--- a/shared/auto/android-info.txt
+++ b/shared/auto/android-info.txt
@@ -1 +1,2 @@
 config=auto
+gfxstream=supported
diff --git a/shared/auto_md/android-info.txt b/shared/auto_md/android-info.txt
index ac7c0e7..1a130ff 100644
--- a/shared/auto_md/android-info.txt
+++ b/shared/auto_md/android-info.txt
@@ -1 +1,2 @@
 config=auto_md
+gfxstream=supported
diff --git a/shared/auto_portrait/android-info.txt b/shared/auto_portrait/android-info.txt
index 60b759e..ea15130 100644
--- a/shared/auto_portrait/android-info.txt
+++ b/shared/auto_portrait/android-info.txt
@@ -1 +1,2 @@
 config=auto_portrait
+gfxstream=supported
diff --git a/shared/foldable/android-info.txt b/shared/foldable/android-info.txt
index 8552685..53cfa11 100644
--- a/shared/foldable/android-info.txt
+++ b/shared/foldable/android-info.txt
@@ -1 +1,2 @@
 config=foldable
+gfxstream=supported
diff --git a/shared/go/android-info.txt b/shared/go/android-info.txt
index 68f4826..ae9578c 100644
--- a/shared/go/android-info.txt
+++ b/shared/go/android-info.txt
@@ -1 +1,2 @@
 config=go
+gfxstream=supported
diff --git a/shared/minidroid/android-info.txt b/shared/minidroid/android-info.txt
index fc79813..50453d6 100644
--- a/shared/minidroid/android-info.txt
+++ b/shared/minidroid/android-info.txt
@@ -1 +1,2 @@
 config=minidroid
+gfxstream=supported
diff --git a/shared/phone/android-info.txt b/shared/phone/android-info.txt
index 2286c3d..169f04d 100644
--- a/shared/phone/android-info.txt
+++ b/shared/phone/android-info.txt
@@ -1 +1,2 @@
 config=phone
+gfxstream=supported
diff --git a/shared/slim/android-info.txt b/shared/slim/android-info.txt
index b0bf39b..e7e5bf0 100644
--- a/shared/slim/android-info.txt
+++ b/shared/slim/android-info.txt
@@ -1 +1,2 @@
 config=slim
+gfxstream=supported
diff --git a/shared/tv/android-info.txt b/shared/tv/android-info.txt
index 8eae902..c438609 100644
--- a/shared/tv/android-info.txt
+++ b/shared/tv/android-info.txt
@@ -1 +1,2 @@
 config=tv
+gfxstream=supported
diff --git a/shared/wear/android-info.txt b/shared/wear/android-info.txt
index 22a5b5e..02e029b 100644
--- a/shared/wear/android-info.txt
+++ b/shared/wear/android-info.txt
@@ -1 +1,2 @@
 config=wear
+gfxstream=supported