summaryrefslogtreecommitdiff
path: root/common/motion_sense.c
diff options
context:
space:
mode:
authorChing-Kang Yen <chingkang@chromium.org>2020-10-14 15:57:21 +0800
committerCommit Bot <commit-bot@chromium.org>2020-11-13 06:29:13 +0000
commitb0f1017dd711f095efdac3db4c743e128c499056 (patch)
treef9c4218183062a4f37ddaf64b0ac6c4cd4ba2c83 /common/motion_sense.c
parent412ace563010211981c83f9063fb2e0ed9c6df3b (diff)
downloadchrome-ec-b0f1017dd711f095efdac3db4c743e128c499056.tar.gz
common: motion_sense: Add spoofing activity
make spoof command able to spoof activity state: ectool motionsense spoof -- NUM activity ACT [EN] [0/1] This commit also remove unused parameter |sensor_num| from list_activities, set_activity, get_activity in ectool. BRANCH=None BUG=b:123434029 TEST=buildall TEST=ectool motionsense spoof 4 activity 4 1 0 ectool motionsense spoof 4 activity 4 ectool motionsense get_activity 4 ectool motionsense spoof 4 activity 4 1 1 ectool motionsense get_activity 4 ectool motionsense spoof 4 activity 4 0 ectool motionsense get_activity 4 ectool motionsense spoof 4 activity 4 1 ectool motionsense get_activity 4 Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I819c156ae7fe50c5cf6216d0f44012d192fb528e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2477393 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'common/motion_sense.c')
-rw-r--r--common/motion_sense.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 4b3f66cd07..f708abb26f 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -1381,6 +1381,55 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args)
#ifdef CONFIG_ACCEL_SPOOF_MODE
case MOTIONSENSE_CMD_SPOOF: {
+ /* spoof activity if it is activity sensor */
+ if (IS_ENABLED(CONFIG_GESTURE_HOST_DETECTION) &&
+ in->spoof.sensor_id == MOTION_SENSE_ACTIVITY_SENSOR_ID) {
+ switch (in->spoof.activity_num) {
+#ifdef CONFIG_BODY_DETECTION
+ case MOTIONSENSE_ACTIVITY_BODY_DETECTION:
+ switch (in->spoof.spoof_enable) {
+ case MOTIONSENSE_SPOOF_MODE_DISABLE:
+ /* Disable spoofing. */
+ body_detect_set_spoof(false);
+ break;
+ case MOTIONSENSE_SPOOF_MODE_CUSTOM:
+ /*
+ * Enable spoofing, but use provided
+ * state
+ */
+ body_detect_set_spoof(true);
+ body_detect_change_state(
+ in->spoof.activity_state, true);
+ break;
+ case MOTIONSENSE_SPOOF_MODE_LOCK_CURRENT:
+ /*
+ * Enable spoofing, but lock to current
+ * state
+ */
+ body_detect_set_spoof(true);
+ break;
+ case MOTIONSENSE_SPOOF_MODE_QUERY:
+ /*
+ * Query the spoof status of the
+ * activity
+ */
+ out->spoof.ret =
+ body_detect_get_spoof();
+ args->response_size =
+ sizeof(out->spoof);
+ break;
+ default:
+ return EC_RES_INVALID_PARAM;
+ }
+ break;
+#endif
+ default:
+ return EC_RES_INVALID_PARAM;
+ }
+ break;
+ }
+
+ /* spoof accel data */
sensor = host_sensor_id_to_real_sensor(in->spoof.sensor_id);
if (sensor == NULL)
return EC_RES_INVALID_PARAM;