I want to get the current angle of the foldable device. like ‘sensors-hal’
’sensors-hal’ log
I/sensors-hal: handle_sns_client_event:201, lid_angle_fusion ts=259153364679072 ns value 2/133/3 133/3 -1/-1 0/ 0/ 0 (0/0/2/2 -0.019/6.946/-0.297 0.069/-0.187/9.949 19)
I/sensors-hal: handle_sns_client_event:201, lid_angle_fusion ts=259154524681832 ns value 2/119/3 119/3 -1/-1 0/ 0/ 0 (0/0/2/2 0.038/8.339/5.776 0.153/-0.158/9.957 4)
I/sensors-hal: handle_sns_client_event:201, lid_angle_fusion ts=259154644657613 ns value 2/104/3 104/3 -1/-1 0/ 0/ 0 (0/0/2/2 -0.354/8.908/2.077 -0.184/-0.177/9.937 2)
I/sensors-hal: handle_sns_client_event:201, lid_angle_fusion ts=259154724670634 ns value 2/ 91/3 91/3 -1/-1 0/ 0/ 0 (0/0/2/2 -0.057/9.234/1.376 0.074/-0.160/9.913 36)
I/sensors-hal: handle_sns_client_event:201, lid_angle_fusion ts=259154844695895 ns value 2/ 75/3 75/3 -1/-1 0/ 0/ 0 (0/0/2/2 -0.033/9.179/-4.082 0.074/-0.167/9.961 0)
I/sensors-hal: handle_sns_client_event:201, lid_angle_fusion ts=259155364658811 ns value 2/ 90/3 90/3 -1/-1 0/ 0/ 0 (0/0/2/2 -0.026/8.980/-0.062 0.091/-0.151/9.945 6)
I/sensors-hal: handle_sns_client_event:201, lid_angle_fusion ts=259155444667978 ns value 2/109/3 109/3 -1/-1 0/ 0/ 0 (0/0/2/2 -0.045/7.791/4.649 0.110/-0.165/9.937 29)
I registered the ‘lid_angle_fusion’ sensor
and com.samsung.permission.SSENSOR permission error occurs.
My android manifest permission
<uses-permission android:name="com.samsung.permission.SSENSOR"/>
<uses-permission android:name="android.permission.SENSORS"/>
Register SensorManager
private lateinit var mSensorManager: SensorManager
private lateinit var mHingeAngleSensor: Sensor
private var mSensorListener: SensorEventListener? = null
private fun setupSensors() {
mSensorManager = getSystemService(SENSOR_SERVICE) as SensorManager
val sensorList: List<Sensor> = mSensorManager.getSensorList(Sensor.TYPE_ALL)
for (sensor in sensorList) {
if (sensor.name.contains("lid_angle_fusion")) {
mHingeAngleSensor = sensor
}
}
mSensorListener = object : SensorEventListener {
override fun onSensorChanged(event: SensorEvent) {
if (event.sensor == mHingeAngleSensor) {
val angle = event.values[0].toInt()
}
}
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
}
}
}
override fun onResume() {
super.onResume()
mSensorManager.registerListener(
mSensorListener,
mHingeAngleSensor,
SensorManager.SENSOR_DELAY_FASTEST
)
}
Permission error
E/SensorService: ... Tried enabling a sensor (lid_angle_fusion Wakeup) without holding com.samsung.permission.SSENSOR
How can I have com.samsung.permission.SSENSOR?
Or is there another way to know the current angle of the foldable device?