[Xposed Framework Modules] mirandam:
Hi,

This module works quite good, but the way to detect the light sensor is too simple and fails.

I have 4 different mobiles that after activating the module present a failing orientation sensor, that is, tilting the mobile gives false values making games like "sky jump" in "pou" unplayable.

It took me a long time to find out where the problem came from as all of them have 200+ apps installed, but finally after checking two identical mobiles, one with xposed (and this module) failing, and another without it functioning correctly, I got to the bottom of the reason.

Finding out which sensor is the light sensor cannot reliably be done just by assuming the handle is 1.

The android.hardware.sensor class has a type defined for the light sensor:

int	TYPE_LIGHT A constant describing a light sensor type.

The code below is from page http://code.tutsplus.com/tutorials/android-barometer-logger-acquiring-sensor-data--mobile-10558

[B]Step 1: Finding the Barometric Sensor[/B]

First, get an instance of the SensorManager class, like this:

SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

Next, query for the Sensor.TYPE_PRESSURE sensor, which is the barometric sensor:

Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE);

Using the SensorManager class and reading sensors doesn't require any special permissions.

[B]Step 2: Registering for Sensor Events[/B]

Now you can register to receive events from the sensor. To do this, you must implement a SensorEventListener and tell the SensorManager class about it.

For example, here’s the structure for an implementation of a SensorEventListener:

class MyListener implements SensorEventListener {
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO
}

@Override
public void onSensorChanged(SensorEvent event) {
// TODO
}
}

Then register for events by telling the SensorManager about your listener:

sensorManager.registerListener(myListenerInstance, sensor,
SensorManager.SENSOR_DELAY_NORMAL);

You can register to receive event updates at different rates. The faster the rate, the more frequent the updates, but also the faster the device battery will drain. Here we use the default rate. Check the return value of the registerListener() call to see if it was successful or not. If true, the sensor is available and the listening has started. If false, the sensor may not be available (for whatever reason).

[B]Step 3: Reading Events[/B]

The class to receive sensor events is generic for all sensors via the SensorEvent class. As such, the SensorEvent value field is an array to handle more data than our single numeric barometric sensor provides. We're only interested in the first value of the array and the timestamp:

@Override
public void onSensorChanged(SensorEvent event) {
long timestamp = event.timestamp;
float value = event.values[0];

// do something with the values
}

Replacing TYPE_PRESSURE with TYPE_LIGHT should be enough to get to the light sensor values the right way.

On the same page you can find more details about how to do that the right way.

Hope this can help to solve the problem as for now I can't use eyepreserver.