使用ADB从损坏的Android设备回收传感器 [英] Recycling sensors from a broken android device using adb
问题描述
我刚刚摔坏了s3。 3年前,它是最好的智能手机之一。
I just broke my s3. 3 years ago it was one of the best smartphones.
问题如何通过USB获得电话惯性传感器的值?
Question How can I get the values of the inertial sensors of the phone via usb?
我想使用设备的加速度计,陀螺仪,磁力计,气压计和gps传感器。
I would like to use the accelerometer, gyroscope, magnetometer, barometer and gps sensors of the device.
假设我们要获取:
- 原始加速度数据这三个轴。
我连接了USB电缆并运行了 adb root
和 adb shell
。好的。
I connected the usb cable and ran adb root
and adb shell
. Ok.
root@android:/ # find / -type d -iname "sensors"
/sys/devices/virtual/sensors
/sys/class/sensors
'/ sys / class /传感器的目录包含:
The '/sys/class/sensors' directory contains:
root@android:/ # ls sys/class/sensors
accelerometer_sensor
barometer_sensor
gyro_sensor
light_sensor
magnetic_sensor
proximity_sensor
问题
即使我倾斜手机,原始尺寸也不会改变。传感器处于待机模式。始终显示相同的值。
The raw measurements do not change even if I tilt the phone. The sensor is in standby mode. It always displays the same values.
root@android:/sys/class/sensors/accelerometer_sensor # cat raw_data
-74,121,1016
我注意到用于控制传感器电源状态的文件夹电源/控件。
I have noticed the folder power/control which controls the power state of the sensor.
root@android:/sys/class/sensors/accelerometer_sensor # cat power/control
auto
我尝试了 echo on / yes / ok / yeah / wtf>电源/控制
,但没有任何变化。
I tried with echo on/yes/ok/yeah/wtf > power/control
but nothing changed.
我记得当手机屏幕工作时,打开一个Android应用程序就足够了具有传感器的权限(例如具有指南针功能的Google Maps)以启用传感器并以恒定速率刷新值。
Java应用程序可能在文件中写了一些东西来激活传感器并读取原始值。
I remember that when I had the screen of the phone working, it was sufficient to open an Android application with sensors' permissions, like Google Maps with the compass feature, to Enable the sensors and get the values refreshed at a constant rate. The Java application probably writes something in a file to activate the sensors and reads the raw values.
如何从外壳激活传感器?
How can I activate the sensors from the shell?
推荐答案
使用
root@:/ # getevent -S
您可以获取所有传感器的列表。.查找一个名为 proximity_sensor的传感器并检索设备名称。
例如。
You can get the list of all sensor.. look for one called "proximity_sensor" and retrieve device name. Ex.
root@:/ # getevent -S
add device 1: /dev/input/event11
name: "compass_sensor"
add device 2: /dev/input/event8
name: "barometer_sensor"
add device 3: /dev/input/event7
name: "light_sensor"
add device 4: /dev/input/event6
name: "proximity_sensor"
您可以看到设备的别名为 event6
As you can see your device is aliased as "event6"
现在,进入目录/ sys / class / input / input6
Now, go inside directory /sys/class/input/input6
cd /sys/class/input/input6
echo 1 > enable # TO ACTIVATE THE SENSOR
echo 0 > enable # TO TURN IT OFF AGAIN
这篇关于使用ADB从损坏的Android设备回收传感器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!