AU: Allow override of "appid" through the lsb-release file.
This will allow us to split Omaha configurations into OEM-specific files.
BUG=6145
TEST=unit tests, tested on device
Change-Id: I1f9b44d2a984988723ec81bf77594161c35460a2
Review URL: http://codereview.chromium.org/5022001
diff --git a/omaha_request_params.cc b/omaha_request_params.cc
index 19bcc6a..6884c83 100644
--- a/omaha_request_params.cc
+++ b/omaha_request_params.cc
@@ -47,7 +47,9 @@
GetLsbValue("CHROMEOS_RELEASE_VERSION", "", NULL) : in_app_version;
os_sp = app_version + "_" + GetMachineType();
os_board = GetLsbValue("CHROMEOS_RELEASE_BOARD", "", NULL);
- app_id = OmahaRequestParams::kAppId;
+ app_id = GetLsbValue("CHROMEOS_RELEASE_APPID",
+ OmahaRequestParams::kAppId,
+ NULL);
app_lang = "en-US";
app_track = GetLsbValue(
kUpdateTrackKey,
diff --git a/omaha_request_params_unittest.cc b/omaha_request_params_unittest.cc
index 65d86cb..77d01d2 100644
--- a/omaha_request_params_unittest.cc
+++ b/omaha_request_params_unittest.cc
@@ -96,6 +96,29 @@
EXPECT_EQ("http://www.google.com", out.update_url);
}
+TEST_F(OmahaRequestDeviceParamsTest, AppIDTest) {
+ ASSERT_TRUE(WriteFileString(
+ kTestDir + "/etc/lsb-release",
+ "CHROMEOS_RELEASE_BOARD=arm-generic\n"
+ "CHROMEOS_RELEASE_FOO=bar\n"
+ "CHROMEOS_RELEASE_VERSION=0.2.2.3\n"
+ "CHROMEOS_RELEASE_TRACK=footrack\n"
+ "CHROMEOS_RELEASE_APPID={58c35cef-9d30-476e-9098-ce20377d535d}\n"
+ "CHROMEOS_AUSERVER=http://www.google.com"));
+ OmahaRequestParams out;
+ EXPECT_TRUE(DoTest(&out, "", ""));
+ EXPECT_EQ("Chrome OS", out.os_platform);
+ EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp);
+ EXPECT_EQ("arm-generic", out.os_board);
+ EXPECT_EQ("{58c35cef-9d30-476e-9098-ce20377d535d}", out.app_id);
+ EXPECT_EQ("0.2.2.3", out.app_version);
+ EXPECT_EQ("en-US", out.app_lang);
+ EXPECT_EQ("", out.hardware_class);
+ EXPECT_TRUE(out.delta_okay);
+ EXPECT_EQ("footrack", out.app_track);
+ EXPECT_EQ("http://www.google.com", out.update_url);
+}
+
TEST_F(OmahaRequestDeviceParamsTest, MissingTrackTest) {
ASSERT_TRUE(WriteFileString(
kTestDir + "/etc/lsb-release",