XaiJu
junesiphone
junesiphone

patreon


Rambling about iOS hardware buttons

Just explaining an issue that came up today. Also a post for me if I need it in the future.

In LockPlus I added an action where if a user presses the volume up button 3 times it would trigger LockPlus to enable or disable LockPlus interaction.

The issue that came up was when a user took a screenshot it would trigger this action. This is not supposed to happen and through my testing never happened.

I got together with Erwinn as he was seeing this issue and I wasn't. We started logging the events of what happened when a screenshot was taken. His logs looked completely different than mine.

My log looks like this when taking a screenshot.

104 = Power Button
102 = Volume Button

By looking at this log I can tell that force 1 is when I pressed the button. Force 0 is when I released the button. I was using 2 iPX at this time one on 13.2.2 and the other on 14.3

Erwinn on the other hand is on an i11 on iOS 14.3. His log looked like this.

We can see he did press the volume up and power button but he has much more activity than I did. Comparing the two I noticed he had phase=2. When writing the code I didn't take into consideration the phases as in my log it didn't seem to matter.  I thought with detecting the press I could see how many times it was pressed. Here is the code I wrote to hook into this.

To break it down I needed something to hold the press count when the press count was 3 then trigger the interaction. I also needed a timer. If a user pressed volume up then 5 seconds later pressed it again the count shouldn't be added. The 3 presses should trigger within a set time. Also if any other button is pressed clear the count as most likely they aren't trying to trigger the action.

I added press counts in this if statement
if(type == 102 && force == 1){

If we take a look at his logs again you can see that type == 102 and force == 1 is called multiple times. The only difference is the phases. I didn't know what the phases were. I looked it up and this is what they were.

On his phone phase = 2 is called multiple times. This means it was saying it was stationary.
"A button was pressed but hasn't moved since the previous event"

Why doesn't my device detect this? I don't know the answer to that question. We tested on the same firmware so it has to be device specific. I think.

Since I really didn't know the answer. I looked at the logs again and noticed that if I did the adding of presses on the release, then we would bypass all this phase nonsense. Another way would be just ignore certain phases, but I think this was a better fix.

The
if(type == 102 && force == 1){
would now be
if(type == 102 && force == 0){

When adding on release I don't have to worry about what happens while the button is held down. It only adds when it's released which means it had to be pressed at some point.

This shows the importance of stating the device model when reporting a bug. He reported this and I tested it. I had no issues but he did. The same goes for firmwares. iOS changes a lot and devices do too. 

We make tweaks and a lot of people expect them to work on all iPhones and Firmwares but it's not that easy. Sometimes I get reports of why you don't fix this bug and in my testing the bug doesn't exist and i've never seen it. I'm sure this is the same with a lot of tweak developers. With the right information from users and sometimes help, developers can fix bugs like this. 

Have a good day!

Comments

Hello Beautiful and minimalistic but is it possible to move the images? Or resize?

Rodrigo v


More Creators