power: Fixes a necessary command in ALSManagerMojo's DCHECK

As DCHECK will disappear from the binary completely in optimized builds,
fixes the bug that ALSManagerMojo puts a necessary command inside a
DCHECK.

BUG=b:214631027
TEST=unit tests

Change-Id: I299b325c4a1ccedba48260781186e40bee62a9a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/3412453
Reviewed-by: Mengqi Guo <mqg@chromium.org>
Commit-Queue: Cheng-Hao Yang <chenghaoyang@chromium.org>
Tested-by: Cheng-Hao Yang <chenghaoyang@chromium.org>
(cherry picked from commit 05271ba182cb6348190145ff920ed4540e0c7a49)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/3414934
diff --git a/power_manager/powerd/system/ambient_light_sensor_manager_mojo.cc b/power_manager/powerd/system/ambient_light_sensor_manager_mojo.cc
index a5d11c1..11da520 100644
--- a/power_manager/powerd/system/ambient_light_sensor_manager_mojo.cc
+++ b/power_manager/powerd/system/ambient_light_sensor_manager_mojo.cc
@@ -377,9 +377,9 @@
   DCHECK(sensor->iio_device_id.has_value());
 
   mojo::Remote<cros::mojom::SensorDevice> sensor_device_remote;
-  DCHECK(sensor_service_handler_->GetDevice(
+  sensor_service_handler_->GetDevice(
       sensor->iio_device_id.value(),
-      sensor_device_remote.BindNewPipeAndPassReceiver()));
+      sensor_device_remote.BindNewPipeAndPassReceiver());
 
   sensor_device_remote.set_disconnect_with_reason_handler(
       base::BindOnce(&AmbientLightSensorManagerMojo::OnSensorDeviceDisconnect,
diff --git a/power_manager/powerd/system/sensor_service_handler.cc b/power_manager/powerd/system/sensor_service_handler.cc
index fb67fbe..993ca12 100644
--- a/power_manager/powerd/system/sensor_service_handler.cc
+++ b/power_manager/powerd/system/sensor_service_handler.cc
@@ -88,15 +88,13 @@
   observers_.RemoveObserver(observer);
 }
 
-bool SensorServiceHandler::GetDevice(
+void SensorServiceHandler::GetDevice(
     int32_t iio_device_id,
     mojo::PendingReceiver<cros::mojom::SensorDevice> pending_receiver) {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-  if (!sensor_service_remote_.is_bound())
-    return false;
+  DCHECK(sensor_service_remote_.is_bound());
 
   sensor_service_remote_->GetDevice(iio_device_id, std::move(pending_receiver));
-  return true;
 }
 
 void SensorServiceHandler::OnSensorHalClientDisconnect() {
diff --git a/power_manager/powerd/system/sensor_service_handler.h b/power_manager/powerd/system/sensor_service_handler.h
index 2a2fc2b..33ef731 100644
--- a/power_manager/powerd/system/sensor_service_handler.h
+++ b/power_manager/powerd/system/sensor_service_handler.h
@@ -48,9 +48,8 @@
   void AddObserver(SensorServiceHandlerObserver* observer);
   void RemoveObserver(SensorServiceHandlerObserver* observer);
 
-  // If |sensor_service_remote_| is bound, calls |SensorService::GetDevice| and
-  // returns true. Returns false if not.
-  bool GetDevice(
+  // Passes |pending_receiver| to |SensorService::GetDevice|.
+  void GetDevice(
       int32_t iio_device_id,
       mojo::PendingReceiver<cros::mojom::SensorDevice> pending_receiver);