TheLastProject / RaiseToAnswer

Simply hold your phone to your ear to answer an incoming call
https://play.google.com/store/apps/details?id=me.hackerchick.raisetoanswer
MIT License
74 stars 13 forks source link

not working out of the pocket #25

Closed kolcsarlevi closed 3 years ago

kolcsarlevi commented 3 years ago

The app works only if the device proximity sensor is not covered during incoming calls by pockets or other items. If the sensor is covered when receiving a call, the app doesnt pick up the phone holding into the ears ( covering again the prox. sensor. ) The device is: Unihertz Atom L Android 10, phone permission allowed, Helio P60 chipset (MTK proximity sensor). Maybe the probmlem is that at first launch the sensor provides only data to the apps when the state is changed, but Im not sure. At this case my phone cannot be used with RaiseToAnswer to pick up the phone out of the pocket?

TheLastProject commented 3 years ago

Hmm, interesting. Does it beep at all if you have "Beep on incoming calls" enabled?

kolcsarlevi commented 3 years ago

No, I have beeps only if the Test or real call starts when the proximity sensor is not covered. No pick up after the covered starting state, even if I uncover and then cover the sensor with my hand or any other thing. I can provide you logs if that helps, just I don't know how to provide it.

kolcsarlevi commented 3 years ago

Sorry, I said wrong about the sound. When doing the test: no call sound when the sensor is covered AND no pickup sound when I uncover and recover the sensor. Look my next attached video:

kolcsarlevi commented 3 years ago

https://user-images.githubusercontent.com/40172594/104470263-d2dde400-55b9-11eb-8b58-b649c001cc3a.mp4

TheLastProject commented 3 years ago

That is really weird. But thank you for the video, that does really help a lot to understand at what points things go wrong. I'll see if I can reproduce this with my own device.

kolcsarlevi commented 3 years ago

That is really weird. But thank you for the video, that does really help a lot to understand at what points things go wrong. I'll see if I can reproduce this with my own device.

I can opt in for the beta app and test for you the changes. Or you can print out logs for me in the beta app and I can make screenshots. This tool can help me in winter, because I cannot pick up the call with gloves on. Thank you so much!

kolcsarlevi commented 3 years ago

Maybe the MTK proximity sensor needs extra initialization before using it properly, I have some test programs where behaves differently. For example one: if covered and opened shows 0 cm, and if not covered and opened: no data. No data uncovered than covered to 0cm and released and than shows the correct 1cm value. But it is dual state 0 or 1, and sometimes no data.

TheLastProject commented 3 years ago

That is very interesting info. Sorry I haven't gotten back to this yet, work has been really busy and all and I haven't really had the time and energy to look into this further. But I very much appreciate all your help in figuring this out!

kolcsarlevi commented 3 years ago

That is very interesting info. Sorry I haven't gotten back to this yet, work has been really busy and all and I haven't really had the time and energy to look into this further. But I very much appreciate all your help in figuring this out!

No problem, I'm helping for the other users too, lot of Mediatek SoC phones are out there from China. Probably a lot of Mediatek based phones behave the same way as mine. The app is very promising if uses almost zero battery and if works well out of pocket.

TheLastProject commented 3 years ago

I added a debug feature to the app, please see the README for how to use it. I hope this will help us get closer to solving this. I've included the .apk in a .zip below so you don't have to compile yourself.

app-debug.zip

kolcsarlevi commented 3 years ago

Installed the apk, I see two apps. In the main app I have no test button unfortunately, and the language is now hungarian. I have another debug app now, where is the README? Thank you!

TheLastProject commented 3 years ago

Yeah I decided to hide the test button by default because I keep getting reviews saying the test button does nothing.

I meant the project README, I added debugging instructions there: https://github.com/TheLastProject/RaiseToAnswer#debugging

The app being Hungarian now makes sense if that is your phone language, Hungarian language support was added after the last stable release

kolcsarlevi commented 3 years ago

When sensor is not covered and working fine:

TEST STARTED INCLINATION -1 INCLINATION 5 MAGNETOMETER -40.96 -6.01 14.11 INCLINATION 4 INCLINATION -3 INCLINATION 1 TIMER RUN START RESET BEEP 1 MAGNETOMETER -41.95 -6.62 13.02 INCLINATION 7 INCLINATION 9 MAGNETOMETER -42.04 -5.21 15.71 INCLINATION 2 INCLINATION 5 TIMER RUN START RESET BEEP 2 INCLINATION 6 MAGNETOMETER -43.26 -4.41 15.93 INCLINATION 7 INCLINATION 8 MAGNETOMETER -44.25 -3.29 16.22 INCLINATION 12 INCLINATION 9 PROXIMITY 0.0 TIMER RUN START ANSWER BEEP 1 MAGNETOMETER -43.26 -3.52 16.41 INCLINATION 10 INCLINATION 8 INCLINATION 14 MAGNETOMETER -43.55 -4.22 15.32 INCLINATION 17 INCLINATION 14 TIMER RUN START ANSWER BEEP 2 MAGNETOMETER -43.55 -4.51 16.32 INCLINATION 13 INCLINATION 13 INCLINATION 16 MAGNETOMETER -43.36 -4.22 15.23 INCLINATION 11 INCLINATION 8 TIMER RUN START PICKUP DETECTED ANSWER BEEP 3 MAGNETOMETER -43.45 -4.41 17.92 INCLINATION 13

kolcsarlevi commented 3 years ago

When sensor covered and no pickup after:

TEST STARTED PROXIMITY 0.0 INCLINATION 12 INCLINATION 11 MAGNETOMETER -38.04 2.68 6.24 INCLINATION 10 INCLINATION 11 TIMER RUN START INCLINATION 11 RESET BEEP 0 MAGNETOMETER -39.07 2.4 6.72 INCLINATION 11 INCLINATION 11 MAGNETOMETER -38.46 2.59 4.64 INCLINATION 12 INCLINATION 11 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.84 2.08 7.23 INCLINATION 12 INCLINATION 11 INCLINATION 11 MAGNETOMETER -38.27 2.78 6.62 INCLINATION 12 INCLINATION 10 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.84 2.08 6.33 INCLINATION 10 INCLINATION 12 INCLINATION 11 MAGNETOMETER -37.66 2.17 6.81 INCLINATION 12 INCLINATION 10 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.75 2.49 7.61 INCLINATION 11 INCLINATION 9 INCLINATION 10 MAGNETOMETER -38.65 1.98 6.52 INCLINATION 11 INCLINATION 11 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.75 1.79 7.13 INCLINATION 11 INCLINATION 11 INCLINATION 9 MAGNETOMETER -39.36 2.17 6.52 INCLINATION 10 INCLINATION 9 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.14 2.49 3.93 INCLINATION 10 INCLINATION 9 INCLINATION 10 MAGNETOMETER -38.36 1.6 7.32 INCLINATION 8 PROXIMITY 1.0 INCLINATION 6 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.56 2.08 6.33 INCLINATION 10 INCLINATION 8 INCLINATION 10 MAGNETOMETER -38.46 1.5 4.22 INCLINATION 7 INCLINATION 8 PROXIMITY 0.0 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.27 0.8 4.51 INCLINATION 10 INCLINATION 7 MAGNETOMETER -39.07 1.18 5.72 INCLINATION 10 INCLINATION 10 INCLINATION 8 TIMER RUN START RESET BEEP 0 MAGNETOMETER -39.26 1.37 4.73 PROXIMITY 1.0 INCLINATION 13 INCLINATION 4 MAGNETOMETER -38.36 1.5 6.72 INCLINATION 8 INCLINATION 8 INCLINATION 8 TIMER RUN START RESET BEEP 0 MAGNETOMETER -37.75 1.37 5.53 INCLINATION 9 INCLINATION 10 MAGNETOMETER -37.85 0.7 5.92 INCLINATION 10 INCLINATION 6 PROXIMITY 0.0 INCLINATION 8 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.84 0.57 6.52 INCLINATION 14 INCLINATION 11 MAGNETOMETER -39.45 1.37 6.62 INCLINATION 9 INCLINATION 12 INCLINATION 10 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.94 0.99 5.21 INCLINATION 11 INCLINATION 9 PROXIMITY 1.0 MAGNETOMETER -37.85 0.7 6.62 INCLINATION 4 INCLINATION 11 INCLINATION 8 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.27 0.7 5.44 INCLINATION 9 INCLINATION 8 MAGNETOMETER -38.84 1.18 7.42 INCLINATION 9 PROXIMITY 0.0 INCLINATION 10 INCLINATION 13 TIMER RUN START RESET BEEP 0 MAGNETOMETER -39.16 1.08 6.11 INCLINATION 10 INCLINATION 11 MAGNETOMETER -38.75 1.6 6.81 INCLINATION 11 INCLINATION 9 TIMER RUN START RESET BEEP 0 MAGNETOMETER -38.65 0.7 5.44 INCLINATION 12 PROXIMITY 1.0 INCLINATION 9 INCLINATION 10 MAGNETOMETER -38.14 0.57 7.42 INCLINATION 9 PROXIMITY 0.0 INCLINATION 16 TIMER RUN START RESET BEEP 0 MAGNETOMETER -39.07 1.37 7.13 INCLINATION 9 INCLINATION 10 INCLINATION 10 MAGNETOMETER -39.26 1.37 6.62 INCLINATION 7 INCLINATION 9 TIMER RUN START RESET BEEP 0 MAGNETOMETER -37.85 0.57 4.12 INCLINATION 12 PROXIMITY 1.0 INCLINATION 7 INCLINATION -3 MAGNETOMETER -35.74 0.57 2.91 INCLINATION -4 INCLINATION 1 TIMER RUN START RESET BEEP 0 MAGNETOMETER -35.45 -1.92 3.23 INCLINATION 0 INCLINATION -2 INCLINATION 6 MAGNETOMETER -36.25 -1.92 4.41 INCLINATION 2 INCLINATION 3 TIMER RUN START RESET BEEP 0 MAGNETOMETER -36.35 -1.12 6.24 INCLINATION 1 INCLINATION 0 INCLINATION 1 MAGNETOMETER -36.25 -0.8 2.43 INCLINATION 3 INCLINATION 2 TIMER RUN START RESET BEEP 0 MAGNETOMETER -35.07 -0.32 3.23 INCLINATION 1 INCLINATION 2 INCLINATION 0 MAGNETOMETER -36.96 -1.92 3.93 INCLINATION 1 INCLINATION -1 TIMER RUN START RESET BEEP 0 MAGNETOMETER -36.44 -1.4 4.51 INCLINATION 2 INCLINATION -3 INCLINATION -1 MAGNETOMETER -36.67 -1.21 4.64 INCLINATION -1 INCLINATION 0 TIMER RUN START RESET BEEP 0 MAGNETOMETER -35.74 -0.32 4.73 INCLINATION -4 INCLINATION -2 MAGNETOMETER -36.44 -1.21 5.02 INCLINATION 1 INCLINATION 3 INCLINATION -2 TIMER RUN START RESET BEEP 0 MAGNETOMETER -36.06 -1.02 3.04 INCLINATION 2 INCLINATION 0 MAGNETOMETER -36.06 -1.21 4.73 INCLINATION 0 INCLINATION 0 INCLINATION 0 TIMER RUN START RESET BEEP 0 MAGNETOMETER -36.06 -1.82 4.41 INCLINATION -1

kolcsarlevi commented 3 years ago

I just repeated the video behavior, first the working state and second "out of pocket". I forgot to turn on the beep so this was without sound notification all two.

TheLastProject commented 3 years ago

Hmm, very interesting your proximity sensor seems to only ever return exactly 0.0 and 1.0. I have written some code to more dynamically calculate the threshold. I think this should help. Can you please test again? Thank you!

app-debug.zip

TheLastProject commented 3 years ago

Oh yeah and please give me the logs again even if it works now. Helps me double-check some things :)

kolcsarlevi commented 3 years ago

Now it works out of pocket, only thing that missing that in your pocket you dont get beeps at first, that is intended? TEST STARTED PROXIMITY SENSOR RANGE DETECTED AS 1.0 SETTING PROXIMITY SENSOR THRESHOLD TO 0.5 PROXIMITY 0.0 INCLINATION 9 INCLINATION 9 MAGNETOMETER -145.37 -21.18 -140.38 INCLINATION 9 INCLINATION 9 INCLINATION 8 TIMER RUN START RESET BEEP 0 MAGNETOMETER -145.47 -21.37 -139.77 INCLINATION 9 INCLINATION 8 MAGNETOMETER -145.98 -21.08 -138.78 INCLINATION 8 INCLINATION 9 TIMER RUN START RESET BEEP 0 INCLINATION 8 MAGNETOMETER -146.27 -21.28 -141.18 INCLINATION 9 INCLINATION 8 MAGNETOMETER -145.79 -20.89 -140.0 INCLINATION 9 INCLINATION 8 TIMER RUN START RESET BEEP 0 MAGNETOMETER -145.69 -21.08 -141.08 INCLINATION 9 INCLINATION 9 INCLINATION 9 MAGNETOMETER -145.6 -21.18 -139.48 INCLINATION 8 INCLINATION 7 TIMER RUN START RESET BEEP 0 MAGNETOMETER -145.08 -21.18 -140.0 INCLINATION 8 INCLINATION 8 INCLINATION 8 MAGNETOMETER -144.67 -20.19 -136.0 INCLINATION 8 INCLINATION 7 TIMER RUN START RESET BEEP 0 MAGNETOMETER -144.89 -19.87 -137.88 INCLINATION 8 INCLINATION 9 INCLINATION 9 MAGNETOMETER -145.18 -20.09 -139.87 INCLINATION 8 INCLINATION 6 TIMER RUN START RESET BEEP 0 MAGNETOMETER -145.79 -21.18 -140.0 PROXIMITY 1.0 INCLINATION 4 INCLINATION 6 INCLINATION 10 MAGNETOMETER -145.79 -21.37 -141.08 INCLINATION 8 INCLINATION 8 TIMER RUN START RESET BEEP 1 MAGNETOMETER -145.88 -21.37 -141.6 INCLINATION 9 INCLINATION 9 INCLINATION 9 MAGNETOMETER -145.88 -21.6 -140.48 INCLINATION 7 INCLINATION 8 TIMER RUN START RESET BEEP 2 MAGNETOMETER -145.47 -21.69 -138.68 INCLINATION 8 INCLINATION 8 INCLINATION 8 MAGNETOMETER -145.98 -21.98 -139.29 INCLINATION 7 INCLINATION 8 TIMER RUN START ANSWER BEEP 0 MAGNETOMETER -145.69 -21.88 -138.97 INCLINATION 7 INCLINATION 6 MAGNETOMETER -145.79 -21.98 -138.78 INCLINATION 6 INCLINATION 8 INCLINATION 9 PROXIMITY 0.0 TIMER RUN START ANSWER BEEP 1 MAGNETOMETER -145.69 -21.88 -138.78 INCLINATION 7 INCLINATION 7 MAGNETOMETER -146.59 -21.37 -138.68 INCLINATION 8 INCLINATION 10 INCLINATION 9 TIMER RUN START ANSWER BEEP 2 MAGNETOMETER -146.49 -21.28 -139.48 INCLINATION 7 INCLINATION 8 MAGNETOMETER -146.27 -21.28 -140.38 INCLINATION 7 INCLINATION 8 INCLINATION 8 TIMER RUN START PICKUP DETECTED ANSWER BEEP 3 MAGNETOMETER -146.59 -21.37 -140.8

kolcsarlevi commented 3 years ago

The sensor has no value between 0.0 and 1.0, only 0.0 and 1.0. It is binary in the prox. test apps.

TheLastProject commented 3 years ago

only thing that missing that in your pocket you dont get beeps at first, that is intended

It actually is. It is supposed to work as follows:

  1. Keep checking every 400 ms if the proximity sensor is not covered (so not in pocked). 1 beep per succesful check. After 2 succesful checks in a row, go to step 2
  2. Keep checking every 400 ms if the proximity sensor is covered and calculate if it's a decline or not based on angle. 1 beep per succesful check of either answer or decline angle. After 3 succesful checks in a row, answer or decline

So it beeping in your pocked was actually a bug because it meant that the app thought it wasn't covered.

But awesome to hear it works. I'll create a new release and publish it to the Google Play Open Testing program and F-Droid. If there are no new crashing popping up during a few days of Beta I'll push it to all users.

Thanks so much for your patience and help in figuring this one out!

Fixed in https://github.com/TheLastProject/RaiseToAnswer/commit/e8b52d66a4420df6ddd76141ef50b13525548b7a :)

kolcsarlevi commented 3 years ago

And at this latest test version the app has no notification bar at the top. Thanks for fixing it!!

kolcsarlevi commented 3 years ago

Sorry I have notification, but I have to run the test for it.

TheLastProject commented 3 years ago

Yeah, I sadly can't do anything about the notification. Newer versions of Android no longer allow apps to read the sensors without being in the foreground and that notification makes it count as being in the foreground. It's an Android limitation. But it only shows while testing or when there's an incoming call.

kolcsarlevi commented 3 years ago

Ok thanks and for the vibration option I will add the translation but I'm away and only in my notebook I can acces it. But you can add the "Beérkező hívásnál rezegjen a telefon." To the vibration setting hungarian translation.

TheLastProject commented 3 years ago

Ah cool, I'll add that to this release :)