iioservice: Specify name attribute in mojom

Add 'name' of iio device as attribute constant to help clients
distinguish ALS sensor devices.

BUG=b:174544536
TEST=unit tests and run on kohaku

Change-Id: I959b3d8af6217b53abdad83cd53dc22685773036
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2595753
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Cheng-Hao Yang <chenghaoyang@chromium.org>
Commit-Queue: Cheng-Hao Yang <chenghaoyang@chromium.org>
diff --git a/iioservice/daemon/sensor_device_impl_test.cc b/iioservice/daemon/sensor_device_impl_test.cc
index a36827a..6101972 100644
--- a/iioservice/daemon/sensor_device_impl_test.cc
+++ b/iioservice/daemon/sensor_device_impl_test.cc
@@ -98,15 +98,17 @@
   base::RunLoop loop;
   remote_->GetAttributes(
       std::vector<std::string>{kDummyChnAttrName1, kDeviceAttrName,
-                               kDummyChnAttrName2},
+                               cros::mojom::kDeviceName, kDummyChnAttrName2},
       base::BindOnce(
           [](base::Closure closure,
              const std::vector<base::Optional<std::string>>& values) {
-            EXPECT_EQ(values.size(), 3u);
+            EXPECT_EQ(values.size(), 4u);
             EXPECT_FALSE(values.front().has_value());
             EXPECT_FALSE(values.back().has_value());
             EXPECT_TRUE(values[1].has_value());
             EXPECT_EQ(values[1].value().compare(kParsedDeviceAttrValue), 0);
+            EXPECT_TRUE(values[2].has_value());
+            EXPECT_EQ(values[2].value().compare(fakes::kAccelDeviceName), 0);
             closure.Run();
           },
           loop.QuitClosure()));
diff --git a/iioservice/mojo/sensor.mojom b/iioservice/mojo/sensor.mojom
index 1d3b092..8539064 100644
--- a/iioservice/mojo/sensor.mojom
+++ b/iioservice/mojo/sensor.mojom
@@ -10,6 +10,9 @@
 const string kSamplingFrequencyAvailable = "sampling_frequency_available";
 const string kLocation = "location";
 
+// The attribute name to get the device name in SensorDevice::GetAttributes.
+const string kDeviceName = "name";
+
 const string kLocationBase = "base";
 const string kLocationLid = "lid";
 const string kLocationCamera = "camera";
@@ -92,6 +95,7 @@
   // Gets the |attr_names| attributes of this device into |values| as strings.
   // When an attribute cannot be read, its value in |values| is set to null.
   // |values| and |attr_names| always have the same size.
+  // Device name (|kDeviceName|) is also an attribute that can be requested.
   GetAttributes@1(array<string> attr_names) => (array<string?> values);
 
   // Sets the frequency in Hz of the device before starting to read samples.