| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "update_engine/omaha_request_params.h" | 5 #include "update_engine/omaha_request_params.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <sys/utsname.h> | 9 #include <sys/utsname.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/file_util.h" |
| 14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 15 #include "update_engine/simple_key_value_store.h" | 16 #include "update_engine/simple_key_value_store.h" |
| 16 #include "update_engine/utils.h" | 17 #include "update_engine/utils.h" |
| 17 | 18 |
| 18 using std::map; | 19 using std::map; |
| 19 using std::string; | 20 using std::string; |
| 20 | 21 |
| 21 namespace chromeos_update_engine { | 22 namespace chromeos_update_engine { |
| 22 | 23 |
| 23 const char* const OmahaRequestParams::kAppId( | 24 const char* const OmahaRequestParams::kAppId( |
| 24 "{87efface-864d-49a5-9bb3-4b050a7c227a}"); | 25 "{87efface-864d-49a5-9bb3-4b050a7c227a}"); |
| 25 const char* const OmahaRequestParams::kOsPlatform("Chrome OS"); | 26 const char* const OmahaRequestParams::kOsPlatform("Chrome OS"); |
| 26 const char* const OmahaRequestParams::kOsVersion("Indy"); | 27 const char* const OmahaRequestParams::kOsVersion("Indy"); |
| 27 const char* const OmahaRequestParams::kUpdateUrl( | 28 const char* const OmahaRequestParams::kUpdateUrl( |
| 28 "https://tools.google.com/service/update2"); | 29 "https://tools.google.com/service/update2"); |
| 29 | 30 |
| 31 static const char kHWIDPath[] = "/sys/devices/platform/chromeos_acpi/HWID"; |
| 32 |
| 30 bool OmahaRequestDeviceParams::Init(const std::string& in_app_version, | 33 bool OmahaRequestDeviceParams::Init(const std::string& in_app_version, |
| 31 const std::string& in_update_url) { | 34 const std::string& in_update_url) { |
| 32 os_platform = OmahaRequestParams::kOsPlatform; | 35 os_platform = OmahaRequestParams::kOsPlatform; |
| 33 os_version = OmahaRequestParams::kOsVersion; | 36 os_version = OmahaRequestParams::kOsVersion; |
| 34 app_version = in_app_version.empty() ? | 37 app_version = in_app_version.empty() ? |
| 35 GetLsbValue("CHROMEOS_RELEASE_VERSION", "") : in_app_version; | 38 GetLsbValue("CHROMEOS_RELEASE_VERSION", "") : in_app_version; |
| 36 os_sp = app_version + "_" + GetMachineType(); | 39 os_sp = app_version + "_" + GetMachineType(); |
| 37 os_board = GetLsbValue("CHROMEOS_RELEASE_BOARD", ""); | 40 os_board = GetLsbValue("CHROMEOS_RELEASE_BOARD", ""); |
| 38 app_id = OmahaRequestParams::kAppId; | 41 app_id = OmahaRequestParams::kAppId; |
| 39 app_lang = "en-US"; | 42 app_lang = "en-US"; |
| 40 app_track = GetLsbValue("CHROMEOS_RELEASE_TRACK", ""); | 43 app_track = GetLsbValue("CHROMEOS_RELEASE_TRACK", ""); |
| 44 hardware_class = GetHardwareClass(); |
| 41 struct stat stbuf; | 45 struct stat stbuf; |
| 42 | 46 |
| 43 // Deltas are only okay if the /.nodelta file does not exist. | 47 // Deltas are only okay if the /.nodelta file does not exist. |
| 44 // If we don't know (i.e. stat() returns some unexpected error), | 48 // If we don't know (i.e. stat() returns some unexpected error), |
| 45 // then err on the side of caution and say deltas are not okay | 49 // then err on the side of caution and say deltas are not okay |
| 46 delta_okay = (stat((root_ + "/.nodelta").c_str(), &stbuf) < 0) && | 50 delta_okay = (stat((root_ + "/.nodelta").c_str(), &stbuf) < 0) && |
| 47 (errno == ENOENT); | 51 (errno == ENOENT); |
| 48 | 52 |
| 49 update_url = in_update_url.empty() ? | 53 update_url = in_update_url.empty() ? |
| 50 GetLsbValue("CHROMEOS_AUSERVER", OmahaRequestParams::kUpdateUrl) : | 54 GetLsbValue("CHROMEOS_AUSERVER", OmahaRequestParams::kUpdateUrl) : |
| (...skipping 21 matching lines...) Expand all Loading... |
| 72 } | 76 } |
| 73 | 77 |
| 74 string OmahaRequestDeviceParams::GetMachineType() const { | 78 string OmahaRequestDeviceParams::GetMachineType() const { |
| 75 struct utsname buf; | 79 struct utsname buf; |
| 76 string ret; | 80 string ret; |
| 77 if (uname(&buf) == 0) | 81 if (uname(&buf) == 0) |
| 78 ret = buf.machine; | 82 ret = buf.machine; |
| 79 return ret; | 83 return ret; |
| 80 } | 84 } |
| 81 | 85 |
| 86 string OmahaRequestDeviceParams::GetHardwareClass() const { |
| 87 string hwid; |
| 88 if (!file_util::ReadFileToString(FilePath(root_ + kHWIDPath), &hwid)) { |
| 89 LOG(ERROR) << "Unable to determine the system hardware qualification ID."; |
| 90 return ""; |
| 91 } |
| 92 TrimWhitespaceASCII(hwid, TRIM_ALL, &hwid); |
| 93 return hwid; |
| 94 } |
| 95 |
| 82 } // namespace chromeos_update_engine | 96 } // namespace chromeos_update_engine |
| OLD | NEW |