Reputation: 774
I have an app which relies on using an Infrared based proximity sensor. Since the Note 10, Samsung have been using virtual proximity sensors - that is, they don't use Infrared, but instead rely on a combination of light sensors, gyroscope, accelerometer etc.
The problem with this is apps that relied on the proximity sensor as gesture input method nolonger work. I would like the ability to detect if the device has an infrared-based proximity sensor or a virtual one, and if not, display an error or offer some other alternative functionality, but right now I can't see a way to distringuish between the two.
For additional context, I want to be able to detect when the user wipes their hand over the sensor without touching the screen (i.e. an inch or two away), but need it to work in the dark and when the phone is lying flat (i.e. not necesserily in vertical position).
sensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE);
proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
if (proximitySensor != null) {
deviceHasProximitySensor = true; //S20 returns true (but has no infrared proximity sensor)
} else {
deviceHasProximitySensor = false; //I need devices without infrared sensor to return false
}
If I call proximitySensor.name
it returns Palm Proximity Sensor version 2
on Samsung Galaxy S20, and proximitySensor.toString
returns {Sensor name="Palm Proximity Sensor version 2", vendor="Samsung", version=1000, type=8, maxRange=5.0, resolution=1.0, power=1.2, minDelay=0}
. I would rather a solution which doesn't rely on hacks for specific hardware.
Upvotes: 3
Views: 986