Bug in "Lets make a tweak" tweak.
Added 2020-03-09 17:46:49 +0000 UTCGreat title. I know, don't rub it in. In "Lets make a tweak" we made a tweak where if you press the power button, if the flashlight was on, it would turn it off.
I found a bug in the tweak.
Bug
A software bug is an error, flaw or fault in a computer program or system that causes it to produce an incorrect or unexpected result, or to behave in unintended ways. The part we're referring to here is "behave in unintended ways".
The flashlight was on, but our tweak did not turn it off. Therefore it's acting in an unintended way. We expected the flashlight to go off.
Come to find out there is a conflict with LockPlus. I also talked about conflicts in this post.
Looking at the LockPlus code I used PSTorchSettingsDetail instead of SBUIFlashlightController to toggle the flashlight.
Why did I use PSTorchSettingsDetail instead the SBUIFlashlightController in LockPlus, but made the power button tweak with SBUIFlashlightController?
PRO TIP: If you hover over methods on the Limneos header site it will show you what firmwares these methods exist in.

As you see this instance method exists in many firmwares back to iOS7. Just by seeing this I know why I used it in LockPlus. They're also instance methods. Which means we can just call them with the class.
In tweaks if we want to call methods from another class we need an instance of that class we are calling.
Example if this header said PSTorchSettingsDetail had the method of -(void)setEnabled:(BOOL)arg1; instead of the instance method +(void)setEnabled:(BOOL)arg1; we would need a way to get the instance of PSTorchSettingsDetail.
This is why you see some tweet things like this.

If you recall when we made the power button tweak we used a sharedInstance of the SBUIFlashlightController so we could call its methods. Not everything will have a sharedInstance though. Sometimes you even have to allocate the class. π³
To turn on the flashlight in LockPlus it calls
[objc_getClass("PSTorchSettingsDetail") setEnabled:YES]; π¦
I find this perfectly fine, but it has some side effects I wasn't aware of. For example if you turn the flashlight on this way, you can't turn it off from the Control Center. The only way to turn it off is by setting setEnabled:NO. I'm sure there is another way, but I just realized this and haven't found another way.
In this scenario i'm not sure the fault. LockPlus is using this because of the firmware coverage, but the power button tweak is using the "correct" way on certain firmwares.
*I say "correct" way because if you enable the flashlight through SBUIFlashlightController you can turn it off through the Control Center.
Thinking more on it, I would say this should be fixed in both tweaks. On PSTorch since this class has a big firmware coverage and it has instance methods it would be better to handle this in the power button tweak.
As for the LockPlus side this needs to be looked into too. The element in LockPlus is a toggle. You tap it once it turns on the flashlight, tap it again it turns it off. If a user turned on the flashlight, then somehow LockPlus stopped functioning they couldn't turn the flashlight off in the control center. That's a problem. The good thing is the odds of this happening is pretty low.
Thanks for reading:)
Comments
Iβve jailbroke my I ipad 7,6. 13.3.1. And bypassed it but even when I donβt turn off iPad the next day itβs all gone and Iβm stuck now Iβve app synced and AFC2 parched so donβt get it missing something
and wat
2020-03-16 01:35:01 +0000 UTC