Commit 6322cd9f authored by Andrei-Laurențiu Olteanu's avatar Andrei-Laurențiu Olteanu Committed by Commit Bot

[Telemetry SWX] Use string for serial

Change serial type from uint32 to string, to ensure a more stable API in
case product serial number is larger than uint8.

Bug: b:160628527
Change-Id: Ia6f97977abffb4569c0c4d7af141ad0d8cdf756d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2294805Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarMahmoud Gawad <mgawad@google.com>
Reviewed-by: default avatarOleh Lamzin <lamzin@google.com>
Commit-Queue: Laurențiu Olteanu <lolteanu@google.com>
Cr-Commit-Position: refs/heads/master@{#789012}
parent ef63f40c
......@@ -31,8 +31,11 @@
// - FanInfo
// - StatefulPartitionInfo
// - BluetoothAdapterInfo
// 3) NonRemovableBlockDeviceInfo: use uint32 to store manufacturer_id instead
// of uint8 in case we want to extend manufacturer range.
// 3) NonRemovableBlockDeviceInfo:
// 3.1) use uint32 to store manufacturer_id instead of uint8 in case we
// want to extend manufacturer range.
// 3.2) use string to store serial in a decimal numeral system instead
// of uint32 in case we want to extend serial number range.
// 4) LogicalCpuInfo:
// 4.1) rename idle_time_user_hz to idle_time_user, because of typo in
// cros_healthd interface;
......@@ -188,8 +191,9 @@ struct NonRemovableBlockDeviceInfo {
UInt32Value? manufacturer_id;
// PNM: Product name, ASCII characters for 6 bytes.
string? name;
// PSN: Product serial number, 32 bits.
UInt32Value? serial;
// PSN: Product serial number, encoded unsigned integer in decimal numeral
// system.
string? serial;
// Bytes read since last boot.
UInt64Value? bytes_read_since_last_boot;
// Bytes written since last boot.
......
......@@ -7,6 +7,7 @@
#include <utility>
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "chromeos/components/telemetry_extension_ui/mojom/probe_service.mojom.h"
#include "chromeos/services/cros_healthd/public/mojom/cros_healthd_probe.mojom.h"
......@@ -88,7 +89,7 @@ health::mojom::NonRemovableBlockDeviceInfoPtr UncheckedConvertPtr(
return health::mojom::NonRemovableBlockDeviceInfo::New(
std::move(input->path), Convert(input->size), std::move(input->type),
Convert(static_cast<uint32_t>(input->manufacturer_id)),
std::move(input->name), Convert(static_cast<uint32_t>(input->serial)),
std::move(input->name), base::NumberToString(input->serial),
Convert(input->bytes_read_since_last_boot),
Convert(input->bytes_written_since_last_boot),
Convert(input->read_time_seconds_since_last_boot),
......
......@@ -168,7 +168,8 @@ TEST(ProbeServiceConvertors, NonRemovableBlockDeviceInfoPtr) {
constexpr char kType[] = "NVMe";
constexpr uint8_t kManufacturerId = 200;
constexpr char kName[] = "goog";
constexpr uint32_t kSerial = 0xaabbccdd;
constexpr uint32_t kSerial = 4287654321;
constexpr char kSerialString[] = "4287654321";
constexpr uint64_t kBytesReadSinceLastBoot = (1ULL << 62) + 222;
constexpr uint64_t kBytesWrittenSinceLastBoot = (1ULL << 61) + 333;
constexpr uint64_t kReadTimeSecondsSinceLastBoot = (1ULL << 60) + 444;
......@@ -198,7 +199,7 @@ TEST(ProbeServiceConvertors, NonRemovableBlockDeviceInfoPtr) {
health::mojom::NonRemovableBlockDeviceInfo::New(
kPath, health::mojom::UInt64Value::New(kSize), kType,
health::mojom::UInt32Value::New(kManufacturerId), kName,
health::mojom::UInt32Value::New(kSerial),
kSerialString,
health::mojom::UInt64Value::New(kBytesReadSinceLastBoot),
health::mojom::UInt64Value::New(kBytesWrittenSinceLastBoot),
health::mojom::UInt64Value::New(kReadTimeSecondsSinceLastBoot),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment