Added "Network downgrade first"-option and fixed unnecessary block calls.#1
Added "Network downgrade first"-option and fixed unnecessary block calls.#1sebikeller wants to merge 11 commits into
Conversation
…lls. "Network downgrade first"-option tries to disable LTE (3G on older devices) to get a stronger signal (and save battery by switching down). After the check-delay (default 300 s) it will attempt to switch back. In some situations where signal changes occured in short intervals and the user did manually turn airplane mode off, it could get turned on several times in a row, since every signal change caused the dispatched block to run. Now it will only queue the block if signal strength is worse or equal than at last change and no block is queued. Also moved duplicate code (from iOS 7 + iOS 8 hooks) to single function. Changed object type of CFPropertyListRef-object (returned from CFPreferencesCopyAppValue) to NSNumber* (was NSString*) to better match the plist data types (CFNumber, CFBool).
|
Hey @joemerlino, Have a nice day. Greez |
|
Hi! if(tryDownGradeNetworkSpeed && percentage>=bars && [[FSSwitchPanel sharedPanel] stateForSwitchIdentifier:@"com.a3tweaks.switch.lte"]==1){
[[FSSwitchPanel sharedPanel] setState:FSSwitchStateOff forSwitchIdentifier:@"com.a3tweaks.switch.lte"];
}
else if(!call && percentage>=bars && [[FSSwitchPanel sharedPanel] stateForSwitchIdentifier:@"com.a3tweaks.switch.airplane-mode"] == 0){...after the delay dispatch? |
Network downgrade now also happens only when signal stays weak for "delay" seconds. Merged "network downgrade" and "airplane-mode" to one block! Fixed some logic, preventing loops of "up-" and "downgrading" the network.
|
I added there the same delayed switching, since it occurred to me several times that I had bad LTE reception for about 10 seconds, and it did already "downgrade" to 3G. |
Recheck reception quality on all paths in block.
|
( Sorry for the many commits, but somehow wanted to keep old .deb's ) |
|
I'm sorry maybe I'm dumb but still not understand, let's make a scenario so we can understand better the situation: You're on LTE and you have low signal (below the set threshold) my code will enter inside this first if: if(enabled && percentage>=bars){
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_main_queue(), ^{so the tweak will wait the set delay, giving the phone the time to downgrade itself as you mentioned before, then if you still have a bad LTE and the option enabled it will just disable LTE: if(tryDownGradeNetworkSpeed && percentage>=bars && [[FSSwitchPanel sharedPanel] stateForSwitchIdentifier:@"com.a3tweaks.switch.lte"]==1){
[[FSSwitchPanel sharedPanel] setState:FSSwitchStateOff forSwitchIdentifier:@"com.a3tweaks.switch.lte"];
}
else if(!call && percentage>=bars && [[FSSwitchPanel sharedPanel] stateForSwitchIdentifier:@"com.a3tweaks.switch.airplane-mode"] == 0){...But if you disabled the option or simply have only a bad 3G connection it's gonna skip the first if but enter inside the else if statement to trigger airplane mode. |
|
Yes I think, you got it. Some flow examples.downgrade option enabled:
downgrade option disabled:
|
If no downgrade was possible, airplaine mode could have been never enabled.
Added listener class to catch changed 3G/LTE Switch Events to reenable "Network downgrade" option.
"Network downgrade first"-option tries to disable LTE (3G on older
devices) to get a stronger signal (and save battery by switching down).
After the check-delay (default 300 s) it will attempt to switch back.
In some situations where signal changes occured in short intervals and
the user did manually turn airplane mode off, it could get turned on
several times in a row, since every signal change caused the dispatched
block to run.
Now it will only queue the block if signal strength is worse or equal
than at last change and no block is queued.
Also moved duplicate code (from iOS 7 + iOS 8 hooks) to single function.
Changed object type of CFPropertyListRef-object (returned from
CFPreferencesCopyAppValue) to NSNumber* (was NSString*) to better match
the plist data types (CFNumber, CFBool).