CTS Verifier测试时出现加速度传感器测试失败的解决。
问题表现:加速度传感器的相关CTS测试出现超时,CTS测试时不能收到加速度传感器的input事件。但是只要测试时晃动手机就能通过测试。
分析:加速度传感器驱动采用上层轮询方式,驱动未工作在中断方式。但这不是问题原因!因为上层对加速度传感器数据的读取采用ioctrl方式,也就是上层会以固定的频率调用驱动的ioctrl接口,每次调用该接口都会触发驱动调用一次input的report动作。从这一点来看和中断方式并无差异。因为上层的轮询频率是固定的,因此驱动上报input事件的频率也是固定的。
那么为什么上层会丢掉事件呢?
当前驱动在注册input设备时配置了如下参数:FUZZ和FLAT,这类似于绘画中的“羽化”处理,也就是会对数据做一些平滑和消抖处理,当连续两次上报的数据小于FUZZ和FLAT的设置时,这次上报的数据会被input系统过滤掉,因此上层就收不到本次的事件了。所以表现为静止状态时,虽然驱动仍旧已上层的轮询频率执行report动作,但是上层却收不到事件。
input_set_abs_params(acc->input_dev, ABS_X, -G_MAX, G_MAX, FUZZ, FLAT);
input_set_abs_params(acc->input_dev, ABS_Y, -G_MAX, G_MAX, FUZZ, FLAT);
input_set_abs_params(acc->input_dev, ABS_Z, -G_MAX, G_MAX, FUZZ, FLAT);
解决:修改如下,去掉防抖设置,这样,哪怕前后两次上报的数据是完全一样的,也不会被过滤。
input_set_abs_params(acc->input_dev, ABS_X, -G_MAX, G_MAX, 0, 0);
input_set_abs_params(acc->input_dev, ABS_Y, -G_MAX, G_MAX, 0, 0);
input_set_abs_params(acc->input_dev, ABS_Z, -G_MAX, G_MAX, 0, 0);
===================附上CTS测试时失败的结果========================
<test-results-report report-version="2" creation-time="Fri Aug 01 12:22:03 GMT+05:30 2014"><verifier-info version-name="4.4_r3" version-code="3"/><device-info><build-info board="sp7731gga_lc" brand="Spreadtrum" device="scx35_sp7731gga_lc" display="scx35_sp7731gga_lcplus_UUIFWVGA_dt-userdebug 4.4.2 KOT49H W14.31.1-02 test-keys" fingerprint="unknown" id="KOT49H" model="SP7730A" product="scx35_sp7731gga_lcplus_UUIFWVGA_dt" release="4.4.2" sdk="19"/></device-info><test-results><test title="Alarms and Timers Tests" class-name="com.android.cts.verifier.deskclock.DeskClockTestsActivity" result="pass"/><test title="Policy Serialization Test" class-name="com.android.cts.verifier.admin.PolicySerializationTestActivity" result="not-executed"/><test title="Screen Lock Test" class-name="com.android.cts.verifier.admin.ScreenLockTestActivity" result="pass"/><test title="Hardware/Software Feature Summary" class-name="com.android.cts.verifier.features.FeatureSummaryActivity" result="not-executed"/><test title="GPS Test" class-name="com.android.cts.verifier.location.GpsTestActivity" result="not-executed"/><test title="USB Accessory Test" class-name="com.android.cts.verifier.usb.UsbAccessoryTestActivity" result="not-executed"/><test title="Battery Saving Mode Test" class-name="com.android.cts.verifier.location.LocationModeBatterySavingTestActivity" result="not-executed"/><test title="Device Only Mode Test" class-name="com.android.cts.verifier.location.LocationModeDeviceOnlyTestActivity" result="not-executed"/><test title="High Accuracy Mode Test" class-name="com.android.cts.verifier.location.LocationModeHighAccuracyTestActivity" result="not-executed"/><test title="Location Mode Off Test" class-name="com.android.cts.verifier.location.LocationModeOffTestActivity" result="not-executed"/><test title="Bluetooth Test" class-name="com.android.cts.verifier.bluetooth.BluetoothTestActivity" result="not-executed"/><test title="CA Cert Notification Test" class-name="com.android.cts.verifier.security.CAInstallNotificationVerifierActivity" result="not-executed"/><test title="CA Cert Notification on Boot test" class-name="com.android.cts.verifier.security.CANotifyOnBootActivity" result="not-executed"/><test title="Notification Listener Test" class-name="com.android.cts.verifier.nls.NotificationListenerVerifierActivity" result="not-executed"/><test title="Data Backup Test" class-name="com.android.cts.verifier.backup.BackupTestActivity" result="not-executed"/><test title="Sample Framework Test" class-name="com.android.cts.verifier.sample.SampleTestActivity" result="not-executed"/><test title="Widget Framework Test" class-name="com.android.cts.verifier.widget.WidgetTestActivity" result="not-executed"/><test title="Keyguard Password Verification" class-name="com.android.cts.verifier.security.LockConfirmBypassTest" result="pass"/><test title="SUID File Scanner" class-name="com.android.cts.verifier.suid.SuidFilesActivity" result="fail"/><test title="Accelerometer Measurement Tests" class-name="com.android.cts.verifier.sensors.AccelerometerMeasurementTestActivity" result="fail"><details>WaitForEvents| Accelerometer (1), handle:0| count:100, available:39, </details></test><test title="Accelerometer Test" class-name="com.android.cts.verifier.sensors.AccelerometerTestActivity" result="not-executed"/><test title="Gyroscope Measurement Test" class-name="com.android.cts.verifier.sensors.GyroscopeMeasurementTestActivity" result="pass"><details>Sensor 'Gyroscope (4)' of type 4 is not supported.</details></test><test title="Streaming Video Quality Verifier" class-name="com.android.cts.verifier.streamquality.StreamingVideoActivity" result="not-executed"/></test-results></test-results-report>