Wednesday 27 July 2016

[Xposed] [Testers needed] Trying to solve Light sensor bug



Hi, may be some of you have experienced the bug when an auto-brightness is on and you're in the dark place or light sensor is covered by your hand or cardboard and you're trying to watch 360 video on youtube or other required gyroscope thing and there are lags. Watch them on video - https://www.youtube.com/watch?v=XYudbTzIdHU
May be it's already been discussed but I haven't found the solution except turning auto-brightness off which isn't like a perfect solution to me :)
On 4pda user GODKIMOVSK have shared some info regarding this problem. Here few things you should know:
1. There are two different kind of light sensor installed on our devices:
a) Liteon LTR55X ALSPRX
b) Sensortek stk3x1x alsprx
A lot of users with gyro bug have Liteon sensor but there are people with second one as well.
To check what sensor is installed on your device use Sensor Box application.
2) The limits of light sensor usually are 0 - 10000 lux and gyro lags exist only when the data from the sensor is less than 10 lux.
So, the solution is quite simple seems to me. When the sensor read value that is less than 10 lux it becomes 10 lux on the out of the sensor.

I found a xposed module http://repo.xposed.info/module/com.m...er.disableprox - which able to mock all sensor 's values on your device. But I haven't tried it yet cause my boot is still locked and I don't want to unlock it unofficially so I'm waiting for xiaomi to allow the unlocking.
The module doesn't able to change light sensor measurement limits but it can replace it with one number. And if it actually does that's almost the solution.

THE FIRST TASK.
I need people which have the described gyro bug to test the Sensor Disabler xposed module.
1. Install the module, activate it in xposed installer. Go to the module setting, find the light sensor and mock its values to 50-100 lux . Reboot.
2. Turn on auto-brightness. Install Sensor Box or any other application which can measure light sensor data. If it shows exactly the same value in lux that you set up in the module then it works.
3. Try to experience gyro lag. Go to youtube and try to watch any 360 video with your hand covering light sensor.
4 . Share your results in this thread. Does the module work or not? Does the lags are gone?
Share xposed log too (/data/data/de.robv..../log/ and the file is error.log or something like that) so if the module doesn't work we can identify what is the reason.


THE SECOND TASK.
I saw source code of Sensor Disabler module and built my own module (Light_Fix.apk) with following code which is aimed to solve the gyro bug.
Test my module as well and share log.
Steps are almost the same except 2nd step:
2. If the data can not go less then 10 lux then my module works.


PHP Code:







private void ChangeSensorValues(final LoadPackageParam lpparam) {
      
         
XC_MethodHook mockSensorHook = new XC_MethodHook() {
                @
SuppressWarnings("unchecked")
                @
Override
                
protected void beforeHookedMethod(MethodHookParam param)
                        
throws Throwable {
                                        
                    
int type=(Integer) param.args[0];
                    
float[] sensor_values=(float[]) param.args[1];
                    
                    if ((
type==) & (sensor_values[0]<=10)) //type 5 - LIGHT_SENSOR afaik
                    
{
                        
XposedBridge.log("SOMETHING WORKS!");
                        
XposedBridge.log("type= "param.args[0]);
                        
XposedBridge.log("values= "param.args[1]);
                        
                        
sensor_values[0]=(float) 10;
                        
param.args[1]=sensor_values;
                    }
                    
                }
            };
            
XposedHelpers.findAndHookMethod("android.hardware.SystemSensorManager$SensorEventQueue"lpparam.classLoader"dispatchSensorEvent"int.class, float[].class, int.class, long.class, mockSensorHook);
 } 









I am also open for help from devs and other people. It's just sad that no one hasn't even tried somehow to solve the gyro bug despite so much people have the phone.

To mods: please move that thread if it is not in appropriate place














Attached Files






File Type: apk LightFix_v2.apk -
[Click for QR Code]
(433.0 KB)







No comments:

Post a Comment