Merge in power and volume button information.

BUG=chromium:1073073
TEST=manual

Cq-Depend: chromium:2249691
Change-Id: I00a3b6e7f2043edae7d43ce67c8afb3c94fb673b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/config/+/2250540
Tested-by: Sean McAllister <smcallis@google.com>
Auto-Submit: Sean McAllister <smcallis@google.com>
Reviewed-by: Andrew Lamb <andrewlamb@chromium.org>
Commit-Queue: Andrew Lamb <andrewlamb@chromium.org>
diff --git a/payload_utils/join_config_payloads.py b/payload_utils/join_config_payloads.py
index 3e44c3b..5fdf70f 100755
--- a/payload_utils/join_config_payloads.py
+++ b/payload_utils/join_config_payloads.py
@@ -210,6 +210,31 @@
   hw_feat.camera.count.value = camera_props.get('count', 0)
 
 
+def merge_buttons(hw_feat, model):
+  """Merge power/volume button information from model.yaml into hardware features.
+
+  Args:
+    hw_feat (HardwareFeatures): hardware features to update
+    model (CrosConfig): parsed model.yaml information
+
+  Returns:
+    None
+  """
+  ui_props = model.GetProperties('/ui')
+  button = topology_pb2.HardwareFeatures.Button
+
+  if 'power-button' in ui_props:
+    edge = ui_props['power-button']['edge']
+    hw_feat.power_button.edge = button.Edge.Value(edge.upper())
+    hw_feat.power_button.position = ui_props['power-button']['position']
+
+  if 'side-volume-button' in ui_props:
+    region = ui_props['side-volume-button']['region']
+    hw_feat.volume_button.region = button.Region.Value(region.upper())
+    side = ui_props['side-volume-button']['side']
+    hw_feat.volume_button.edge = button.Edge.Value(side.upper())
+
+
 def merge_hardware_props(hw_feat, model):
   """Merge hardware properties from model.yaml into the given hardware features.
 
@@ -320,6 +345,7 @@
   merge_fingerprint_config(hw_feat, model)
   merge_hardware_props(hw_feat, model)
   merge_camera_config(hw_feat, model)
+  merge_buttons(hw_feat, model)
 
   # Merge software configuration
   sw_config = config_bundle.software_configs.add()