Sensor enable/disable added to dvr api
In order to manage power usage when system isn't being used.
Bug: None
Test: None
Change-Id: I64f9c3064cc75c1522fef0adef9a5fc156f336b0
diff --git a/libs/vr/libvrsensor/include/dvr/pose_client.h b/libs/vr/libvrsensor/include/dvr/pose_client.h
index 43a8e74..d684ddc 100644
--- a/libs/vr/libvrsensor/include/dvr/pose_client.h
+++ b/libs/vr/libvrsensor/include/dvr/pose_client.h
@@ -119,7 +119,7 @@
// Freezes the pose to the provided state.
//
// Future poll operations will return this state until a different state is
-// frozen or dvrPoseSetMode() is called with a different mode. The timestamp is
+// frozen or dvrPoseClientModeSet() is called with a different mode. The timestamp is
// not frozen.
//
// @param client Pointer to the pose client.
@@ -131,13 +131,13 @@
//
// @param mode The requested pose mode.
// @return Zero on success, negative error code on failure.
-int dvrPoseClientSetMode(DvrPoseClient* client, DvrPoseMode mode);
+int dvrPoseClientModeSet(DvrPoseClient* client, DvrPoseMode mode);
// Gets the pose service mode.
//
// @param mode Return value for the current pose mode.
// @return Zero on success, negative error code on failure.
-int dvrPoseClientGetMode(DvrPoseClient* client, DvrPoseMode* mode);
+int dvrPoseClientModeGet(DvrPoseClient* client, DvrPoseMode* mode);
// Get access to the shared memory pose ring buffer.
// A future pose at vsync <current> + <offset> is accessed at index:
@@ -151,6 +151,12 @@
int dvrPoseClientGetRingBuffer(DvrPoseClient* client,
DvrPoseRingBufferInfo* out_info);
+// Sets enabled state for sensors pose processing.
+//
+// @param enabled Whether sensors are enabled or disabled.
+// @return Zero on success
+int dvrPoseClientSensorsEnable(DvrPoseClient* client, bool enabled);
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/libs/vr/libvrsensor/include/private/dvr/pose-ipc.h b/libs/vr/libvrsensor/include/private/dvr/pose-ipc.h
index 9603f1b..e4455f1 100644
--- a/libs/vr/libvrsensor/include/private/dvr/pose-ipc.h
+++ b/libs/vr/libvrsensor/include/private/dvr/pose-ipc.h
@@ -16,6 +16,7 @@
DVR_POSE_GET_MODE,
DVR_POSE_GET_CONTROLLER_RING_BUFFER,
DVR_POSE_LOG_CONTROLLER,
+ DVR_POSE_SENSORS_ENABLE,
};
#ifdef __cplusplus
diff --git a/libs/vr/libvrsensor/pose_client.cpp b/libs/vr/libvrsensor/pose_client.cpp
index 2166597..b21c7cf 100644
--- a/libs/vr/libvrsensor/pose_client.cpp
+++ b/libs/vr/libvrsensor/pose_client.cpp
@@ -130,6 +130,16 @@
return ReturnStatusOrError(status);
}
+ // Enables or disables all pose processing from sensors
+ int EnableSensors(bool enabled) {
+ Transaction trans{*this};
+ Status<int> status = trans.Send<int>(DVR_POSE_SENSORS_ENABLE, &enabled,
+ sizeof(enabled), nullptr, 0);
+ ALOGE_IF(!status, "Pose EnableSensors() failed because: %s\n",
+ status.GetErrorMessage().c_str());
+ return ReturnStatusOrError(status);
+ }
+
int GetRingBuffer(DvrPoseRingBufferInfo* out_info) {
// First time mapping the buffer?
const auto vsync_buffer = GetVsyncBuffer();
@@ -277,17 +287,17 @@
return PoseClient::FromC(client)->Freeze(*frozen_state);
}
-int dvrPoseClientSetMode(DvrPoseClient* client, DvrPoseMode mode) {
+int dvrPoseClientModeSet(DvrPoseClient* client, DvrPoseMode mode) {
return PoseClient::FromC(client)->SetMode(mode);
}
-int dvrPoseClientGetMode(DvrPoseClient* client, DvrPoseMode* mode) {
+int dvrPoseClientModeGet(DvrPoseClient* client, DvrPoseMode* mode) {
return PoseClient::FromC(client)->GetMode(mode);
}
-int dvrPoseClientGetRingBuffer(DvrPoseClient* client,
- DvrPoseRingBufferInfo* out_info) {
- return PoseClient::FromC(client)->GetRingBuffer(out_info);
+
+int dvrPoseClientSensorsEnable(DvrPoseClient* client, bool enabled) {
+ return PoseClient::FromC(client)->EnableSensors(enabled);
}
} // extern "C"