Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

hardware-libsensors: Commit

hardware/libsensors


Commit MetaInfo

Révision0a39d58fb8b6ced7dc6c2cd1043f76554ee805ee (tree)
l'heure2018-01-30 15:04:53
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

Add back the setDelay function

According to https://source.android.com/devices/sensors/versioning

"Implement the batch function

... It replaces setDelay. setDelay will not be called anymore."

However, it is wrong. The setDelay is still called sometimes
as show in the system_server crashing log:

01-26 18:36:11.536 27879 27879 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-26 18:36:11.536 27879 27879 F DEBUG : Build fingerprint: 'Android-x86/android_x86_64/x86_64:7.1.2/N2G48H/cwhuan01041741:userdebug/test-keys'
01-26 18:36:11.536 27879 27879 F DEBUG : Revision: '0'
01-26 18:36:11.537 27879 27879 F DEBUG : ABI: 'x86_64'
01-26 18:36:11.537 27879 27879 F DEBUG : pid: 24500, tid: 27162, name: Binder:24500_12 >>> system_server <<<
01-26 18:36:11.537 27879 27879 F DEBUG : signal 11 (SIGSEGV), code 128 (SI_KERNEL), fault addr 0x0
01-26 18:36:11.537 27879 27879 F DEBUG : rax 332f83dbf746df52 rbx 0000794e04c48500 rcx 0000000000000000 rdx 0000000001312d00
01-26 18:36:11.537 27879 27879 F DEBUG : rsi 0000000000000000 rdi 0000794e04d19000
01-26 18:36:11.537 27879 27879 F DEBUG : r8 0000794df0f4f7b0 r9 0000794e0c62d47a r10 000000000000006e r11 0000000000000246
01-26 18:36:11.537 27879 27879 F DEBUG : r12 0000794e04c1b938 r13 0000000001312d00 r14 0000794e04c48518 r15 0000000000000000
01-26 18:36:11.537 27879 27879 F DEBUG : cs 0000000000000033 ss 000000000000002b
01-26 18:36:11.537 27879 27879 F DEBUG : rip 0000794e0af228ca rbp 0000794e04c1b920 rsp 0000794decc04fc0 eflags 0000000000010206
01-26 18:36:11.542 27879 27879 F DEBUG :
01-26 18:36:11.542 27879 27879 F DEBUG : backtrace:
01-26 18:36:11.542 27879 27879 F DEBUG : #00 pc 00000000000128ca /system/lib64/libsensorservice.so
01-26 18:36:11.542 27879 27879 F DEBUG : #01 pc 000000000001e51b /system/lib64/libsensorservice.so
01-26 18:36:11.542 27879 27879 F DEBUG : #02 pc 00000000000151af /system/lib64/libsensorservice.so

Change Summary

Modification

--- a/hdaps.c
+++ b/hdaps.c
@@ -89,6 +89,13 @@ static int device__activate(struct sensors_poll_device_t *dev, int handle,
8989 return 0;
9090 }
9191
92+static int device__set_delay(struct sensors_poll_device_t *device, int handle,
93+ int64_t ns) {
94+ forced_delay = ns / 1000;
95+ return 0;
96+
97+}
98+
9299 static int device__poll(struct sensors_poll_device_t *device,
93100 sensors_event_t *data, int count) {
94101
@@ -304,6 +311,7 @@ static int open_sensors(const struct hw_module_t* module, const char* name,
304311 dev->device.common.module = (struct hw_module_t*) module;
305312 dev->device.common.close = common__close;
306313 dev->device.activate = device__activate;
314+ dev->device.setDelay = device__set_delay;
307315 dev->device.poll = device__poll;
308316 dev->device.batch = device__batch;
309317 dev->device.flush = device__flush;
--- a/kbdsensor.cpp
+++ b/kbdsensor.cpp
@@ -64,6 +64,7 @@ struct SensorPollContext : SensorFd<sensors_poll_device_1> {
6464 private:
6565 static int poll_close(struct hw_device_t *dev);
6666 static int poll_activate(struct sensors_poll_device_t *dev, int handle, int enabled);
67+ static int poll_setDelay(struct sensors_poll_device_t *dev, int handle, int64_t ns);
6768 static int poll_poll(struct sensors_poll_device_t *dev, sensors_event_t *data, int count);
6869 static int poll_batch(struct sensors_poll_device_1* dev, int sensor_handle, int flags, int64_t sampling_period_ns, int64_t max_report_latency_ns);
6970 static int poll_flush(struct sensors_poll_device_1* dev, int sensor_handle);
@@ -90,6 +91,7 @@ SensorPollContext::SensorPollContext(const struct hw_module_t *module, struct hw
9091 {
9192 common.close = poll_close;
9293 activate = poll_activate;
94+ setDelay = poll_setDelay;
9395 poll = poll_poll;
9496 batch = poll_batch;
9597 flush = poll_flush;
@@ -187,6 +189,14 @@ int SensorPollContext::poll_activate(struct sensors_poll_device_t *dev, int hand
187189 return 0;
188190 }
189191
192+int SensorPollContext::poll_setDelay(struct sensors_poll_device_t *dev, int handle, int64_t ns)
193+{
194+ ALOGD("%s: dev=%p handle=%d ns=%" PRId64, __FUNCTION__, dev, handle, ns);
195+ SensorPollContext *ctx = reinterpret_cast<SensorPollContext *>(dev);
196+ ctx->sampling_period_ns = ns;
197+ return EXIT_SUCCESS;
198+}
199+
190200 int SensorPollContext::poll_poll(struct sensors_poll_device_t *dev, sensors_event_t *data, int count)
191201 {
192202 ALOGV("%s: dev=%p data=%p count=%d", __FUNCTION__, dev, data, count);
@@ -198,9 +208,7 @@ int SensorPollContext::poll_batch(struct sensors_poll_device_1* dev, int sensor_
198208 {
199209 ALOGD("%s: dev=%p sensor_handle=%d flags=%d sampling_period_ns=%" PRId64 " max_report_latency_ns=%" PRId64,
200210 __FUNCTION__, dev, sensor_handle, flags, sampling_period_ns, max_report_latency_ns);
201- SensorPollContext *ctx = reinterpret_cast<SensorPollContext *>(dev);
202- ctx->sampling_period_ns = sampling_period_ns;
203- return EXIT_SUCCESS;
211+ return poll_setDelay(&dev->v0, sensor_handle, sampling_period_ns);
204212 }
205213
206214 int SensorPollContext::poll_flush(struct sensors_poll_device_1* dev, int sensor_handle)
--- a/s103t_sensor.c
+++ b/s103t_sensor.c
@@ -37,6 +37,12 @@ static int context__activate(struct sensors_poll_device_t *dev, int handle, int
3737 return 0;
3838 }
3939
40+static int context__setDelay(struct sensors_poll_device_t *dev, int handle, int64_t ns)
41+{
42+ ALOGD("%s: called", __FUNCTION__);
43+ return 0;
44+}
45+
4046 static int context__close(struct hw_device_t *dev)
4147 {
4248 ALOGD("%s: called", __FUNCTION__);
@@ -189,6 +195,7 @@ static int open_sensors(const struct hw_module_t* module, const char* id, struct
189195
190196 ctx->device.common.close = context__close;
191197 ctx->device.activate = context__activate;
198+ ctx->device.setDelay = context__setDelay;
192199 ctx->device.poll = context__poll;
193200 ctx->device.batch = context__batch;
194201 ctx->device.flush = context__flush;
--- a/w500_sensor.c
+++ b/w500_sensor.c
@@ -138,6 +138,17 @@ static int context__activate(struct sensors_poll_device_t *dev,
138138 return -EINVAL;
139139 }
140140
141+static int context__setDelay(struct sensors_poll_device_t *dev,
142+ int handle, int64_t ns)
143+{
144+ struct sensor_context* ctx = (struct sensor_context *)dev;
145+
146+ ctx->delay.tv_sec = 0;
147+ ctx->delay.tv_nsec = ns;
148+
149+ return 0;
150+}
151+
141152 static int context__close(struct hw_device_t *dev)
142153 {
143154 struct sensor_context* ctx = (struct sensor_context *)dev;
@@ -348,10 +359,7 @@ static int context__batch(struct sensors_poll_device_1* dev, int sensor_handle,
348359 ALOGD("%s: dev=%p sensor_handle=%d flags=%d sampling_period_ns=%" PRId64 " max_report_latency_ns=%" PRId64,
349360 __FUNCTION__, dev, sensor_handle, flags, sampling_period_ns, max_report_latency_ns);
350361
351- struct sensor_context* ctx = (struct sensor_context *)dev;
352- ctx->delay.tv_sec = 0;
353- ctx->delay.tv_nsec = sampling_period_ns;
354- return EXIT_SUCCESS;
362+ return context__setDelay(&dev->v0, sensor_handle, sampling_period_ns);
355363 }
356364
357365 static int context__flush(struct sensors_poll_device_1* dev, int sensor_handle)
@@ -431,6 +439,7 @@ static int open_sensors(const struct hw_module_t *module, const char* id,
431439 ctx->device.common.close = context__close;
432440
433441 ctx->device.activate = context__activate;
442+ ctx->device.setDelay = context__setDelay;
434443 ctx->device.poll = context__poll;
435444 ctx->device.batch = context__batch;
436445 ctx->device.flush = context__flush;
Afficher sur ancien navigateur de dépôt.