Avoid accessing failed HIDL Return contents

It's invalid to attempt to read the contents of a HIDL Return object
that has isOk() return false. This leads to a crash, so instead map
isOk() == false to DEAD_OBJECT in places where the return status is
used, and avoid otherwise avoid referencing the contents of the Return.

To facilitate testing, also add some additional informational logs for
cases when the sensor handles have changed after HAL restart.

Bug: 133497927
Test: use customized 2.0 HAL that crashes in activate call, confirm the
      HAL crash doesn't trigger system server crash due to invalid use
      of Return object
Change-Id: Ic094999ef20d90b538f757e34167155e83711b3d
diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h
index e8685c2..e99ad9b 100644
--- a/services/sensorservice/SensorDevice.h
+++ b/services/sensorservice/SensorDevice.h
@@ -213,12 +213,12 @@
 
     static void handleHidlDeath(const std::string &detail);
     template<typename T>
-    static Return<T> checkReturn(Return<T> &&ret) {
+    static void checkReturn(const Return<T>& ret) {
         if (!ret.isOk()) {
             handleHidlDeath(ret.description());
         }
-        return std::move(ret);
     }
+    static status_t checkReturnAndGetStatus(const Return<Result>& ret);
     //TODO(b/67425500): remove waiter after bug is resolved.
     sp<SensorDeviceUtils::HidlServiceRegistrationWaiter> mRestartWaiter;